Re: [Zope-dev] RAM Cache Manager "next_cleanup" not working?
Hi all, Looking into lib.python.Products.standardCacheManagers.RAMCacheManager.py I found something it looks like a problem in the code and I came to a solution which solves the problem in subject althougt I dont know If this is a safe solution, It works for me. - In RAMCacheManager.RAMCache.ZCache_set() there is a set of the Cache Manager's next_cleanup variable. - With this var we can then test if its time to cleanup and if yes call the self.cleanup() method. But this test is never made in the RAMCacheManager code, except at calls to ZCache_set!?! - At the top of ZCache_set() there is this code: now = time.time() if self.next_cleanup <= now: self.cleanup() self.next_cleanup = now + self.cleanup_interval I think this code should also exist at the top of the method ZCache_get. I put it the following code at the top of the ZCache_set(): now = time.time() if self.next_cleanup <= now: self.next_cleanup = now + self.cleanup_interval return default I think the right thing to do here is to call self.cleanup instead of returning default but then again there is something strange in the cleanup method, because it only tests for the threshold limit and never tests the cleanup_interval constraint. I will change the cleanup method to my needs and call it where I'm doing the "return default". Anyone seen this problem / is working on this? Best Regards, Julio Dinis Silva
From: "Júlio Dinis Silva" <juliodinis@hotmail.com> To: kevinsl@yahoo.com CC: zope-dev@zope.org Subject: [Zope-dev] Re: [Zope] RAM Cache Manager "next_cleanup" not working? Date: Wed, 18 Jul 2001 12:23:58 +0100
Hi,
From Zope-2.3.1 CHANGES.txt: -Fixed two mistakes in the RAM cache cleanup code. Dont know if this was related, but I've tested the simple example on the email below with 230, 231, 232, 233 getting the same problem, i.e, cleanup after 5 seconds doesnt happens.
Doing a search form "ram cache" in the collector I found: Zope Question: Cache Problem Submitted: 2001/06/28 * * * This item is under review * * * Anyone?
Best Regards, Julio Dinis Silva
From: Kevin L <kevinsl@yahoo.com> To: "Júlio" Dinis Silva <juliodinis@hotmail.com>, zope-dev@zope.org, zope@zope.org Subject: Re: [Zope] RAM Cache Manager "next_cleanup" not working? Date: Tue, 17 Jul 2001 14:29:40 -0700 (PDT)
Hi, I'm having the same problem.
I have two dtml methods cached via a RAM Cache Manager. Cleanup Interval is set to 1800 (30 minutes), but the methods never expire (unless I restart zope).
I'm running Zope 2.3.2 binary release on linux.
any ideas?
thanks
-Kevin
--- Júlio Dinis Silva <juliodinis@hotmail.com> wrote:
Hi,
I implemented a Ram Cache Manager. I cached some methods and they really get cached, but the cleanup_interval is not working, i.e, if I define in my Ram Cache Manager a cleanup interval of 5 seconds I will not see my method's cache being updated after that small amount of time. Only using the invalidate button of my method's cache tab I'm able to cleanup and soo refresh the method's cache.
I've been looking into the code and there is something weird with StandardCacheManagers.RAMCacheManager because the ZCache_set which defines the next_cleanup time, is never called unless at __init__ time.
This cache properties are well embeded into OFS.DTMLMethod and OFS.DTMLDocument and so my approach to the code will take some more time, but a simple test with 232 and 233 dont work.
My simple test is:
-create a RAMCacheManager, say "mycache" -create a dtml method "test1" with the code <dtml-var ZopeTime> -create a dtml document "test2" with the code <dtml-var ZopeTime> -associate test1 and test2 with "mycache" -define a cleanup interval of 5 seconds and a threshold entries of 1 and then call "test1" and "test2" several times until more than 5 seconds had passed.
Isnt suppose to after 5 seconds I get a different value from my method or document, in this case, a diferent zopetime?
Is there anyone really using RAM Cache Manager with success, i.e, can you prove to me the cleanup_interval works? Or else there must be something really big I'm missing here.
Meanwhile I'll look into the code.
Best Regards, Julio Dinis Silva
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
__________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
_________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
_________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
"Júlio Dinis Silva" wrote:
Looking into lib.python.Products.standardCacheManagers.RAMCacheManager.py
I found something it looks like a problem in the code and I came to a solution which solves the problem in subject althougt I dont know If this is a safe solution, It works for me.
The theory behind the current solution is that a cache cleanup operation occurs: - only if a certain amount of time has passed since the last cleanup, and - only when adding a new entry to the cache. Then, even during a cleanup, nothing is removed if the number of entries is below the threshold. The idea is that cache hits should be as fast as possible. Cleanup occurs on cache misses instead. The only side effect is that watching for entries to get cleaned up on the stats page won't act as you might expect. The number of entries will *always* go above the threshold. The entries will be cleaned up next time there's a cache *miss*. This is *not* a bug. But maybe we could "fix" it by executing a cleanup every time users look at the stats page. :-) Another idea is for you to create your own cache manager. In fact we (Digital Creations) encourage the creation of alternate cache managers. Shane
participants (2)
-
J�lio Dinis Silva -
Shane Hathaway