Invalidating object(s) in the Zope RAM Cache
Hi, Sorry in advance if this should go to another list. Some background: We have built a content management system on top of Zope Products (incl. CMF) and a custom product for storing the actual content. Because our site is quite large, has a lot of visitors, and gets many, many requests per day, we have a Zope RAM cache set-up to "lighten the load". Generally speaking, the cache saves us, as most of our content isn't sticky, and when edits are made, the cache has normally been invalidated. However some of our content, like article indexes, need to be as up-to-date as possible and the cache is getting in the way. So, the question is: Is there a way that I can invalidate an object from the Zope RAM cache using the Zope API? I did have a brief look in some of the available docs, but didn't find anything... Cheers, Elfyn -- Elfyn McBratney, ABCtales elfyn@ABCtales.com http://www.ABCtales.com/ "Everyone has a story to tell."
Elfyn McBratney wrote at 2003-12-10 16:50 -0000:
... So, the question is: Is there a way that I can invalidate an object from the Zope RAM cache using the Zope API?
Sure: you can do it from the ZMI (Ram Cache Manager --> "Statistics" --> cache entry --> "Invalidate"). Thus, you can do it via the API (as the ZMI does precisely that). Look how the ZMI does it. -- Dieter
Dieter Maurer wrote:
Elfyn McBratney wrote at 2003-12-10 16:50 -0000:
... So, the question is: Is there a way that I can invalidate an object from the Zope RAM cache using the Zope API?
Sure: you can do it from the ZMI (Ram Cache Manager --> "Statistics" --> cache entry --> "Invalidate"). Thus, you can do it via the API (as the ZMI does precisely that). Look how the ZMI does it.
Sorry, my post was lacking in detail. I have been doing it via the ZMI but it's a bit tedious to have to do that everytime an article is posted. =) I'll hunt for the source... *should have done that in the first place* :-) Cheers, Elfyn -- Elfyn McBratney, ABCtales elfyn@ABCtales.com http://www.ABCtales.com/ "Everyone has a story to tell."
Elfyn McBratney wrote:
Dieter Maurer wrote:
Elfyn McBratney wrote at 2003-12-10 16:50 -0000:
... So, the question is: Is there a way that I can invalidate an object from the Zope RAM cache using the Zope API?
Sure: you can do it from the ZMI (Ram Cache Manager --> "Statistics" --> cache entry --> "Invalidate"). Thus, you can do it via the API (as the ZMI does precisely that). Look how the ZMI does it.
Sorry, my post was lacking in detail.
I have been doing it via the ZMI but it's a bit tedious to have to do that everytime an article is posted. =) I'll hunt for the source... *should have done that in the first place* :-)
self.ZCacheable_invalidate() clears the whole cache provided self is an object subclassed from Cache.Cacheable If you want to clear a single cache entry its a little more complicated. I do it with: c = self.ZCacheable_getCache() if c is not None: keywords = { ... my cache keys ...} try: oc = c.getObjectCacheEntries(self) index = oc.aggregateIndex(view_name, None, c.request_vars, keywords) oc.delEntry(index) except AttributeError: ... do something .... - peter.
participants (3)
-
Dieter Maurer -
Elfyn McBratney -
Peter Sabaini