I think... from gluon.contrib.memdb import MEMDB session.connect(request, response, db=MEMDB(cache.ram))
On Apr 5, 11:14 pm, Iceberg <iceb...@21cn.com> wrote: > Hi, does anyone know, is there a way to store session in memory? Even > this means sessions will be lost if web2py restarts, but that is fine > for some non-critical apps. Besides, this way we don't need to worry > about cleaning up the old sessions anymore. And perhaps slightly > faster. > > I have tried these in models/db.py but failed. > > (1) > db=SQLDB('sqlite:memory:') # Actually here we get a new empty db > everytime > session.connect(request,response,db=db) # So sessions in last mem db > can not bring to next click. > > (2) > db=cache.ram('sqlmem',lambda:SQLDB('sqlite:memory:'),3600) > session.connect(request, response, db=db) > # It is tricky but doesn't work. Because this way sqlite complains > multi thread accessing one db instance. > > (3) > Actually I tried some more complicated code, trying to backup raw > session data in cache.ram, and read them back into a new empty sqlite > memory db. It almost works, but I don't know when I shall do the > backup. The current session data seems not exist yet when the db.py is > executing? > > Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---