I would say there are a lot of factors involved, which may be enough to make you not want to do it.
1. You'd have to pick a good species that is tough but does not have tiny spines that can hurt the animal. Many cacti have hairs and small spines, but some have large woody spines that would not be an issue for them.
2. You do have the option of placement, you could put your cactus in a place that is unreachable for the gecko, and therefore eliminate the concern for spines. However this may be difficult to do in a visually appealing manner.
3. Leos love to climb on everything and have small sharp claws. I tried aloe plants and spineless succulents with a few of my leos a long time ago. They walked ALL OVER the plants creating small puncture marks all over the leaves. Succulents do not handle being punctured all over well, and so they died. I did try a different kind of setup later, and found that my female leo was determined to dig and hide in the root area of the plant...this also killed it.
IF you were to try this out I would suggest spineless succulents (there are some cacti bred to be spineless but most get fairly large for a gecko tank) and keep the plant in it's pot. If you do let you crickets roam the cage 24/7 as the other people mentioned above I would not put a cactus in because given the chance the crickets will eat the cacti which is bad for both the cacti and probably the gecko.
Personally I have sucessfully kept a Corn Cob African Milk Bush Cactus – Euphorbia (which is technically not a cactus but looks just like one, it has long woody spines that are actually remnants of flower stalks that are spine shaped!), spineless optunia (these can get 2-3 feet wide, but if you care for them right you can successfully keep them small, and they are true pad cacti. I also have another type of spineless succulent but I do not know the name, if I find it's name I'll post it.