note 102494 added to memcached.sessions
| From: | Tobias at osu1 dot php dot net | Date: | Thu, 17 Feb 2011 15:35:24 +0000 |
| Subject: | note 102494 added to memcached.sessions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177070@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 64.71.164.2
Probable Submitter: 70.91.82.193
----
Manual Page -- http://www.php.net/manual/en/memcached.sessions.php
Edit -- https://master.php.net/note/edit/102494
Del: integrated -- https://master.php.net/note/delete/102494/integrated
Del: useless -- https://master.php.net/note/delete/102494/useless
Del: bad code -- https://master.php.net/note/delete/102494/bad+code
Del: spam -- https://master.php.net/note/delete/102494/spam
Del: non-english -- https://master.php.net/note/delete/102494/non-english
Del: in docs -- https://master.php.net/note/delete/102494/in+docs
Del: other reasons-- https://master.php.net/note/delete/102494
Reject -- https://master.php.net/note/reject/102494
Search -- https://master.php.net/manage/user-notes.php