You need a genetic variant that is pretty well studied and doesn't have too many effects, just a small handful that are well characterized.
A well characterized variant is in ALDH2. [1] People with normal ALDH2 metabolize alcohol normally. Those with variant ALDH2 process acetaldehyde poorly, so this unpleasant metabolite remains in their blood longer, causing discomfort and flush. Those with 0 variant alleles drink more than those with 1 allele; those with both mutations in alleles drink the least.
Let's say you had some variant like that, but for spicy food metabolism. The more variants in this spicy food metabolism gene, the more spicy the food felt to you so you might eat less.
If those who would be genetically expected to tolerate more spicy food survived longer than you would otherwise expect in a (genetic) dose-dependent fashion, then this would be suggestive that spicy food intake might be in the causal pathway of longevity. You would have to do additional work to be sure that the gene didn't do other things in metabolism (pleiotropy) that directly had effects on longevity.