Memcached PHP Sessions

Marcus Bointon marcus at synchromedia.co.uk
Thu Feb 1 21:56:13 UTC 2007


On 1 Feb 2007, at 21:30, Aaron Kalsnes wrote:

> Is there a better way to handle sessions, preferably where we  
> wouldn't have to hit the database so much? Is "session caching"  
> something that exists?

Sure, just make sure you maintain the sessions in memcache with the  
same care as you do your DB version. Make sure you set the session  
key to expire at the appropriate time whenever you get a hit, make  
sure you delete it from memcache when they log out. No particular  
reason to use the DB at all, other than persistence through server  
outages, and for that I use sharedance anyway.

You could keep a 'Who's currently logged in' list in memcached too,  
though you'd have to maintain that manually as you can't do arbitrary  
queries on the memcache store.

Marcus
-- 
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
marcus at synchromedia.co.uk | http://www.synchromedia.co.uk/




More information about the memcached mailing list