[Zope-dev] Session Objects?
Stuart 'Zen' Bishop
zen@cs.rmit.edu.au
Wed, 24 May 2000 19:34:55 +1000 (EST)
On Tue, 23 May 2000, Adam Pawliuk wrote:
> Although there is several user characteristics that we would like to store in a session object cached in server RAM, such as the user's unique system ID, greeting name, etc; rather than having to hit the DB for this information on each request. Basically we would like to use something similar to the session objects in ASP (yuck), or Java JSP/servlet model.
>
> I've seen several Zope session products although they all seem to hook directly to a DB and don't seem to provide memory persistence which is what we would like to use.
>
> Is there any existing products which do this?
Boring old ZSQL Methods actually do exactly what you want - check out the
caching options under the advanced tab (or the ZSQL docs on zope.org).
The database will only be hit the first time you call the method with
a given set of parameters, or when maximum time to cache expires.
If your GUF hooks make use of ZSQL methods, you should have a look
at tuning these too as it can be a big performance improvement.
Actually - I tell a slight lie. The DB might be hit once for each
thread, as the ZSQL cache is not shared between Zope threads. You need
to be aware of this as a cached result may be refreshed in one thread
but not yet expired in another and can give ambiguous results and
unreproducable bugs if you are not aware of it when you are developing.
--
___
// Zen (alias Stuart Bishop) Work: zen@cs.rmit.edu.au
// E N Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au
//__ Computer Science, RMIT WWW: http://www.cs.rmit.edu.au/~zen