memcache PHP session handler redundancy
Sascha Braun - CEO at Braun Networks
sascha at braun-networks.com
Thu Jul 26 00:19:39 UTC 2007
The session class I posted here has a single problem which will
cause that the session will get lost from time to time.
To fix the problem you cave to initialize the handler function
via session_set_save_handler after the session has been initialized.
The code looks simply like that:
// initialize session management
$session = new session_mm($_REQUEST);
session_set_save_handler(array(&$session, "handler_open"),
array(&$session, "handler_close"),
array(&$session, "handler_read"),
array(&$session, "handler_write"),
array(&$session, "handler_destroy"),
array(&$session, "handler_garbage"));
Then everything should work fine.
:)
Am Mittwoch, den 25.07.2007, 22:25 +0200 schrieb Sascha Braun - CEO @
Braun Networks:
> Here Dude, I found a nice class for doing database
> driven session handling in php5 on the web. It was
> open source, so I can easely send you the improved
> version with memcached support.
>
> But the memcached function to load or store data
> into memcache you will still write on your own,
> because its only supporting my application model.
>
> Best Regards,
>
> Sascha
>
> Am Mittwoch, den 25.07.2007, 13:07 -0700 schrieb mike:
> > On 7/25/07, Martin Minka <martin.minka at gmail.com> wrote:
> >
> > > The session handler is using power of more memcache servers to store
> > > sessions, but it does not support redundancy and in case that one of
> > > this memcache servers is lost, some sessions are lost.
> >
> > i use a database (mysql) for this.
> >
> > memcached imho is too volatile (by design) for me. unless session data
> > does not change too often and i can issue the reads into the cache, i
> > wouldn't bother personally. perhaps for a site with millions of users
> > though. not sure. you might have to look into a hybrid method of
> > committing to both places in the off chance you restart memcached, the
> > data is pushed out due to LRU, etc.
> >
> > (biggest thing is user experience and how important the data is in the
> > session store)
> >
More information about the memcached
mailing list