Resetting RAM Cache Manager on COREBlog entry edits
As seen in previous posts (Experiments with RAM cache and RAMcache for COREBlog update), I'm using a RAMCacheManager in Zope to speed up the weblog loading and to ease load on the server. So far the downside has been that after editing a post I had to manually reset the cache. This would even be the case when I would preview a post multiple times before adding it. Not the best solution and definitely an itch that needed scratching...
The solution is to invalidate the RAM cache on edits. That is done in the manage_editEntry method of the Entry class. I'm cacheing the entry_body dtml method, so I have to reset the cache for that one. On the positive side this works and is much easier for me, editing existing posts and previewing behaves now just as if my COREBlog wasn't cached. The downside is that there could be unneeded cache resets, as I always reset. Also the resetting happens for all posts, not just for this entry. Anyway, here is the patch:
--- Entry.py_orig Mon Dec 19 14:18:54 2005 +++ Entry.py Mon Dec 19 14:39:18 2005 @@ -267,6 +267,9 @@ if not title: kw['worning_message'] = "Title is required." + # invalidate the cache if this entry is cached: + self.entry_body.ZCacheable_invalidate() + if REQUEST: if sendnow and addedtbs: #send trackback