memcached for PHP session data

Perrin Harkins perrin at
Mon Dec 5 12:43:12 UTC 2005

On Mon, 2005-12-05 at 01:25 -0700, Denis Antipov wrote:
> I'm trying to cache the session data to our site using memcached but
> once in a while, as in any cache the data would 'disappear' and be
> overwritten by the new session data.

Does it disappear or does it get overwritten with new data?  Those are
not the same thing.

> The problems is that even though the stats command indicate that bytes
> are at about 50% of total_max_bytes the data is being lost on average
> about 20%.

Maybe one of your cache servers went down.  Maybe your clients don't all
agree on the number of servers that are up, and are hashing across them
differently.  Maybe there's a bug in your PHP client code.

This sort of issue is the reason why you shouldn't use memcached as your
primary storage for sessions.  Keep it in a database and just cache it
in memcached.

- Perrin 

More information about the memcached mailing list