php sessions and memcache

Andy memcached at thwartedefforts.org
Tue Jul 18 01:59:21 UTC 2006


On Mon, 2006-07-17 at 16:29 -0500, Richard Thomas wrote:
> The problem is extra overhead, no matter what you do serialize and 
> unserialize are called.
> 
> So on a read you have to serialize the data even though its already in a 
> user format, on write you have to unserialize the input to your write 
> function.
> 
> Thats 2 serializes called that shouldn't be needed if you could disable 
> the sessions serializer.
> 
> That little overhead was enough that in my tests it wasn't really worth it.

Agreed.  The code I currently have does call serialize on the received
session values before sticking them in mysql -- using memcached, this
would not be necessary and the raw value could be passed, letting the
memcached client code do the serialization.  I essentially replaced the
entire session handler with an object that implements the PHP5 array
interfaces -- the PHP set_session_handler code is completely bypassed
(except for setting the cookie).

It was actually written to see if session updating race conditions could
be avoided when, using Ajax, multiple interleaved code paths run
against, and update, the same session.

-- 
Andy <memcached at thwartedefforts.org>



More information about the memcached mailing list