6 ms·
TL;DR: Had no database so I made a PHP page with a hardcoded array of 100,000 coupon codes. --- Made a PHP landing page for a customer where they could redeem
by JohnBooty 3y ago
TL;DR: Had no database so I made a PHP page with a hardcoded array of 100,000 coupon codes.
---
Made a PHP landing page for a customer where they could redeem a coupon code they were sent via snail mail. About 100,000 codes were sent out via USPS.
Threw together the basic code you might expect, simple PHP page + MySQL database. Worked locally because customer was dragging their feet with getting me login creds to their webhost.
Finally, with the cards in the mail, they get me the login creds at 5PMish. I login and there's no database. Cards are going to be arriving in homes as early as 8AM the next day. How TF am I going to make this work... without a database?
Solution... I just hardcoded all 100,000 codes into a giant MySQL array. Or maybe it was a hash/dict or something. I forget.
Anyway, it performed FINE. The first time you used the page it took about 30 seconds to load. But after that, I guess `mod_php` cached it or something, and it was fine. Lookups returned in 100ms or so. Not spectacular but more than performant enough for what we needed.
Got paid. Or, well, my employer did.