Times have been tough for retailers lately. Instead of getting a boost from lower gas prices and unemployment, the big-box stores have gotten hammered as Americans' shopping habits shift to the online channel.

As Amazon.com (AMZN 1.30%) convinces more consumers to join its Prime loyalty program with free two-day shipping and builds out services like Prime Now, which offers delivery in as fast as one hour, it's become harder for brick-and-mortar retailers to compete. According to analyst estimates, Amazon captured 51% of applicable growth in retail over the holiday season as traditional powerhouses like Wal-Mart Stores and Macy's reported declining profits. Wal-Mart and Macy's were also among a slew of retailers, including Kohl's and Sears, to announce store closings shortly after the holiday season.

In this environment, very few retailers have thrived -- but one surprising winner has managed to buck the trend. 

This may be the opposite of Amazon
Dollar General (DG -0.08%) has quietly outperformed almost every other retailer since the recession, benefiting from the combination of a friendly macroeconomic environment and a smart strategy.

The chart below shows the steady increase in Dollar General's key financials in recent years. 

DG Chart

DG data by YCharts

In the last five years, the stock price has nearly tripled as earnings per share have more than doubled. Operating income in that period only increased 50%, but aggressive share repurchases and reduced interest expenses helped leverage those gains.  

During the recession, dollar stores became a fashionable play as consumers traded down to cheaper goods, but Dollar General has been able to thrive even as the economy has recovered.

A macroeconomic trifecta
The company just reported its 26th straight year of comparable sales growth, a streak virtually unmatched in retail, and a testament to the strength of the company's business model. It can prosper through a recession and a strong economy.

Today, macroeconomic conditions are a significant tailwind of Dollar General, unlike in much of retail. While unemployment has fallen considerably since the recession, wage gains have been slow and income inequality has increased, meaning Dollar General's low-income demographic is only growing, and still depends on the company's blend of convenience and value. 

Similarly, low gas prices have given poorer Americans extra spending money, driving cigarette sales up as tobacco companies saw their first growth year since 2006 last year. Lower-income Americans are also more likely to smoke, and are using part of their savings at the gas pump on tobacco. In its recent earnings report, management said it saw significant increases in candy and snacks, perishables, tobacco, and food. Like tobacco, candy and snacks are discretionary purchases that may be also be driven by savings from lower gas prices.

Finally, the company has more than 12,000 stores, but all are in the U.S., meaning the strong dollar has not been a headwind the way it has for multinational retailers or consumer products companies. A stronger dollar may even be an advantage for retailers as it makes imported goods cheaper.

What Amazon can't match
If there's been one winning category in the brick-and-mortar world, it's been convenience. Not only dollar stores have flourished; drugstore chains that offer a similar level of ubiquity, offering convenience that even Amazon can't match, have done well too.

Dollar General knows its target demographic. It's sponsored NASCAR races and advertises in small-town newspapers. It's eschewed fashionable growth trends like organic foods, focusing instead on low-end groceries and other affordable goods.

Similarly, while other retailers have invested substantially in e-commerce operations to keep Amazon at bay, Dollar General only launched online sales in 2011, and has invested its money in opening new stores instead. It knows that its customers aren't going to pay $99 a year for Amazon Prime membership, giving it some protection against Amazon's primary customer acquisition tool. Its minimum of $40 for free online shipping even beats Amazon, which just raised it from $35 to $50.

After EPS grew 13% last year, Dollar General outlined a long-term goal of 11% to 17% EPS growth. With 900 new stores planned for next year and an impeccable track record of same-stores sales growth, I'd expect the company to hit its mark.