views:

12

answers:

1

My recent discovery of memcache has kind of created a craze and opening up everything to new possibilities.

Right now, when I send out a confirmation email when someone has signed up for one of our services, I create "token" in a "tokens" table that has a set expiration (usually 3 days) for them to verify their account.

I then have a daily cron job go through and see if anything is past due, in which case it deletes the token.

Is this something that could be done with memcache? Perhaps a better question -- is this something that should be done with memcache?

+3  A: 

Should? No. Memcache is a transient memory cache, which means that any data it holds could disappear at any moment, or at least you should work under that assumption. Your app should be fully functional even if nothing gets stored in memcache at all. In fact, a reasonably common testing technique is to create a dummy memory cache that doesn't store any data in the cache at all. (It has the methods to store and retrieve data, but they don't do anything) Once you're satisfied your app works with the dummy cache, then you swap it out and put in the real memcache.

In practice, it would probably work most of the time, since unless your computer crashes or runs low on memory, memcache won't just delete stuff arbitrarily because it feels like it. But I'd consider it bad practice to use memcache for something like this.

David Zaslavsky
That was what I was thinking but wasn't sure -- thanks!
Kerry