Rising gas prices are inspiring drivers to find new ways of protecting themselves against future increases—including buying gas in advance and investing in stocks that tend to rise along with the price of gasoline.

One new company, MyGallons.com, lets customers buy gallons ahead of time based on the current prices in their area—in theory, locking in a lower price—and then redeem those gallons at a later date, regardless of any price increases in the interim.

Consumers can also invest in oil companies, coal companies, and other stocks that are likely to benefit from more expensive oil. "Look for companies that will benefit indirectly from oil prices and directly from increased energy efficiency," says Paul Larson, editor of Morningstar StockInvestor. That way, he says, consumers can balance higher expenses at the pump with higher returns on their investments.

At MyGallons.com, the company makes those investments itself. Founder Steve Verona says that the company protects itself against future gas price increases through taking positions in the stock market. That way, customers can enjoy the simplicity of purchasing and redeeming gallons for an established amount and avoid experiencing market fluctuations themselves. Verona says the company doesn't plan to make money on gas, but rather from the annual membership fee (about $30), the interest float on the money that is paid before the gas is redeemed, and advertising on its website.

For consumers interested in hedging their own bets, one option is investing in oil companies. "When gas prices go up, generally oil prices have gone up, and that raises [oil companies'] revenue," Larson says. He also suggests looking for companies that benefit indirectly from rising oil prices, such as railroads, which are a more energy efficient way of moving cargo over long distances than trucks. "That's why railroads are doing so well today," Larson adds.

Oil exploration companies such as Southwestern Energy also offer a way of protecting oneself against future gas price increases, says Peter Cohan, president of a management consulting and venture capital firm that bears his name. In addition, he recommends coal companies, including Walter Industries, Arch Coal, and Peabody Energy, since coal can be used as an energy source instead of oil. Alternative-energy companies, on the other hand, tend to be overvalued right now, Cohan says, and he advises staying away from them.

Of course, gas prices could come down, which could turn any of these investment ideas into losing propositions. As with all investments, says Tim Maurer, director of financial planning for Financial Consulate, a Baltimore advisory firm, consumers need to be prepared to stomach volatility. In fact, his firm has recently limited its exposure to oil in expectation of a short-term market correction.

If prices do indeed fall, then what will happen to MyGallons.com customers' prepurchased gallons? Verona says most people will simply hold on to them until prices go back up again.

But what if prices are currently at their peak and don't go up again? Verona says that's unlikely. "Very few analysts expect prices to come down...because current demand is increasing, while supply has stayed steady. We're talking years, if not decades, before [proposed] solutions have any impact. In the interim, prices should continue to rise," Verona says. He adds that if customers opt to drop out of the program, they can get a refund for their purchased gallons.