Memcache for storing Sessions

Events happening in the community are now at Drupal community events on www.drupal.org.
DREAMER_ES's picture

Hello everyone!
I'm rather new to this group and I need some advice.
I'm trying to build a high performance multisite in EC2 cloud and I have the following question: How can I use memcache for storing sessions and still mantain the "Who's online" functionality and session persistance.

There's a good article that talks about this (sorry I've lost the link) that propose a dump of memcache sessions to DB every N seconds, but I can't find an implementation and I'm thinking in implementing a kind of cron job to do it.

I'm not using memcachedb as I still want to mantain the lighting speed of memcache and a delay in stats and persistance is tolerable for me.

Well, I'm open for your comments and advices!
Thank you so much in advance!

Comments

Sessions will be persistent

everyz's picture

Sessions will be persistent in memcache as far as I know - memcache php extension implements that.

Humm.. yes, I guess isn't

DREAMER_ES's picture

Humm.. yes, I guess isn't that important for me that the sessions survive a memcache flush/restart/reconfigure as mantain drupal's session stats.

You can configure dedicated

everyz's picture

You can configure dedicated memcached instance for sessions handling only

Yes, I know, in fact is what

DREAMER_ES's picture

Yes, I know, in fact is what I have configured, but, the question is: How to dump that cache to the "sessions" DB table in order to keep the "Who's online" and other session related DB-bound functionality working.

not sure, but...

mtsanford's picture

You're probably going to have to write your own memcache-session.inc. The one that comes with the memcache drupal module updates the access field of the user table every 360 seconds. (in sess_write() funciton) If you put some code to write out the session data to the DB if X seconds had elapsed, then that would probably do what you need. You could also query on the user table's access field to get "who's online" data, instead of the session table.

memcache

taducphuong83's picture

We cannot use memcache memcache-session.inc ?

memcache-session.inc

DREAMER_ES's picture

@taducphoung83, we are talking of using memcache-session.inc but adding code to dump the sessions stored in memcache to the database in order to mantain the core and contributed modules' code and functionality that uses the 'sessions' table.