Code to store PHP sessions within memcached.
roze at roze.lv
Fri Nov 17 16:06:49 UTC 2006
You dont need to keep that in mind if you use memcache as session store, it
doesnt have the same restrictions as with file handles cause you practically
cant lock a memcache data item/key.
You can make a simple test to see that this is true:
// there goes the previous session_set_save_handler() memcache functions
$_SESSION['test'] = 'some data';
// there goes the previous session_set_save_handler() memcache funcctions
then you open the first and in the same time second script.
You'll see that short.php will finish instantly (not in the default file
storage case). Although of course short.php will get the 'test' variable
only after 100 seconds (as the write is done at the end of the script if you
dont do the session_write_close manually) but thats only important only in
some cases (in which you wont use ajax requests anyway). So there is no need
to bother that one ajax request takes more time to complete cause the whole
session wont be blocked.
----- Original Message -----
From: "Mauro N. Infantino" <mauroi at digbang.com>
To: "'Reinis Rozitis'" <roze at roze.lv>
Sent: Friday, November 17, 2006 2:58 PM
Subject: RE: Code to store PHP sessions within memcached.
> Keep in mind that the standard php session module locks the whole session
> until the request finishes (or the user calls session_write_close) .
> supplied could lead to problems when using frames or ajax (Is not thaaat
> transparent. Even when not using frames it could happen, but it's less
> probable). I could send the code implementing locking using memcache's add
> method, if you want.
>  Take a look at
> Under "Observing the Race Condition"
More information about the memcached