note 102494 deleted from memcached.sessions by googleguy

From: Date: Mon, 11 Feb 2013 05:15:12 +0000
Subject: note 102494 deleted from memcached.sessions by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193584@lists.php.net to get a copy of this message
Note Submitter: Tobias ---- You probably don't want to use Memcache, Memcached or anything else similar for storing sessions (in RAM via memcached daemon server), because those sessions can easily be thrown away/discarded, become unreachable for various reasons, and then your user gets logged out without warning. What memcache is great for, in general, is storing the results of an SQL or MongoDB query, using the md5() has of the query itself as the key lookup. For example, for all database queries, get the md5() hash of the query, then look for that key in memcache. If it's found, great, grab the results, check they're not too old / outdated, and use them if okay. Otherwise, pass through the query to underlying storage-based DB, then save its results into memcache before passing them back to your app. This general applicability of how, when, where and why to use memcache to greatest advantage and least pain isn't so easy to find on the web. Memcached module is great for new features, etc. (except now it's almost one year since update) but it's difficult to tell when a memcached daemon goes away, crashes, becomes unreachable. Memcache at least has ->connect() method which will report failure/unreachability, but its features are behind. These two projects are moving targets, competing, and it would be nice to get both together, so we can all benefit from best efforts. Meanwhile, what a mess, and what a charm!

« previous php.notes (#193584) next »