Ram Caching under Zope 3 - The return from the cache


Tue 08 March 2005 By nuxeo

I thaught this would be very complicated to set up memory
caching in Zope 3, as I needed a tool that would be enough low
level to be integrated into my objects.



Thread safeness... availabilty... v prefix to avoid .....




But it's very simple in fact :



from zope.app.cache.ram import RAMCache



collection_name = 'BigObjects'

my_super_cache = RAMCache()


caching

object_to_cache = BigObjectJustInRam()

my_super_cache.set(object_to_cache, 'unique_key',
collection_name)



object_to_cache2 = BigObjectJustInRam()

my_super_cache.set(object_to_cache2, 'unique_key_2',
collection_name)




retrieving

the_return_from_the_cache =
my_super_cache.query(collection_name, 'unique_key')

the_return_from_the_cache2 =
my_super_cache.query(collection_name, 'unique_key_2')


empty cache

my_super_cache.invalidate(collection_name)












(Post originally written by Tarek Ziadé on the old Nuxeo blogs.)


Category: Product & Development