Replace asp session with Memcached

Dawei Wang at
Tue May 8 15:50:24 UTC 2007


I am currently working on Replace asp session with Memcached, has anyone
worked on this before and can give me some idea about this?

Thanks a lot.

We have more than one webserver and more than one applications on each
server... and following is my thought and some problems ,if anyone can help
me out,  that would be really cool...

To replace session with Memcached, we have two problems need to figure out:
1. Key for Session*

We all know that asp session is saved for each application, so we can use
session("user_id"), all applications will works fine because session is
stored in different place for dirrerent application.
but in memcache, all will be saved to the same place : memcached server, so
we have to make sure the key is unique.

solution: use sessionID as key prex to implement this.

In our current system, session is stored in one webserver, if switching to
another webserver, session will lose. we need to make sure all webservers
get the same key for the same website.

solution: store sessionID in cookie, even webserver is changed, cookie is
still there, so SessionID is not changed, then session varables saved in
memcached will not lose.

How to simulate the behavior as asp session?

solution: set all session values in memcached to expire in 24 hours,
and sessionID
saved in cookie expires when browser is closed ( this is default) or we can
set sessionID saved in cookie never expired for special communities.

When any page in the application is loaded , we should set all the related
session varibles in Memcached to expire in another 24 hours, how can we
implement this?

solution: write a single page which is included by all pages in this
application, in this page, first get sessionID ,then update all session
varibles whose key starts with sessionID. but Memcached API does not apply
search key function, we have to figure out this....

*2. Override Asp Session object*

We don't want to change our current code, so we need to override asp session
object, we need to figure out how to implement the following without
changing code:

session("a") = "a" & session("a")

solution: ???

Dawei Wang
iUpload(r) | | 1-866-487-5623

Email: at
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list