[Zope3-Users] Using RAMCache

Thierry Florac thierry.florac at onf.fr
Tue Jul 3 11:54:31 EDT 2007


Le mardi 03 juillet 2007 à 13:47 +0200, Dominique Lederer a écrit :
> hi
> 
> i would like to cache the results of method in a view, and thougt, that RAMCache
> could be of use here.
> 
> After spending a lot of time searching for some documentation or examples, i
> came to this:
> 
> from zope.app.cache.ram import RAMCache
> cache = RAMCache()
> query = cache.query('test',key={'x':1})
> if query == None:
> 	result = expensive_stuff_method()
>   	cache.set(result, 'test', key={'x':1})
> 	return result
> else:
> 	return query
> 
> but that won´t work, the cache looses it´s entry, if i call the browser-view again.

First of all, I thing that you can implement a RAM cache manager as a
utility into your site, and then just get to it via
zapi.queryUtility('IRAMCache').
But I didn't use RAM cache until now so I'm not sure if everything is OK
with them...

  Thierry Florac
-- 
  Chef de projet intranet/internet
  Office National des Forêts - Département Informatique
  2, Avenue de Saint-Mandé
  75570 PARIS Cedex 12
  Mél : thierry.florac at onf.fr
  Tél. : +33 01.40.19.59.64
  Fax. : +33 01.40.19.59.85



More information about the Zope3-users mailing list