Re: [Zope3-dev] (zope/app/cache/ram.py) class Storage's cleanup problem.
Hi Stephan, Is these code all right? Regards, SimonOn 11/13/05, Simon Hang [EMAIL PROTECTED] wrote: Thanks Stephan, Here is the test:(test_ramcache.py) class TestStorage(TestCase): def test_getEntry(self): --snipped-- def test_getEntry_do_cleanup(self): from zope.app.cache.ram import Storage s = Storage(cleanupInterval=300, maxAge=300) object = 'object' key = ('view', (), ('answer', 42)) value = 'yes' s.setEntry(object, key, value) s._data[object][key][1] = time() - 400 s.lastCleanup = time() - 400 try: s.getEntry(object, key) except KeyError: pass else: raise cleanup not called def test_setEntry(self): --snipped-- On 11/12/05, Stephan Richter [EMAIL PROTECTED] wrote: On Tuesday 01 November 2005 05:10, Simon Hang wrote: Dear all, I'm happen to find out call Storage only do cleanup when new Entry comes and do nothing when entries get from storage. So entries will be next expired if there are only read activities.I agree with your analysis and solution. If you provide a test for the fix,I'll check it in. If you cannot write a test, please add least add an issueto the issue collector. Regards,Stephan--Stephan RichterCBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student)Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] (zope/app/cache/ram.py) class Storage's cleanup problem.
On Tuesday 01 November 2005 05:10, Simon Hang wrote: Dear all, I'm happen to find out call Storage only do cleanup when new Entry comes and do nothing when entries get from storage. So entries will be next expired if there are only read activities. I agree with your analysis and solution. If you provide a test for the fix, I'll check it in. If you cannot write a test, please add least add an issue to the issue collector. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] (zope/app/cache/ram.py) class Storage's cleanup problem.
Thanks Stephan, Here is the test:(test_ramcache.py) class TestStorage(TestCase): def test_getEntry(self): --snipped-- def test_getEntry_do_cleanup(self): from zope.app.cache.ram import Storage s = Storage(cleanupInterval=300, maxAge=300) object = 'object' key = ('view', (), ('answer', 42)) value = 'yes' s.setEntry(object, key, value) s._data[object][key][1] = time() - 400 s.lastCleanup = time() - 400 try: s.getEntry(object, key) except KeyError: pass else: raise cleanup not called def test_setEntry(self): --snipped-- On 11/12/05, Stephan Richter [EMAIL PROTECTED] wrote: On Tuesday 01 November 2005 05:10, Simon Hang wrote: Dear all, I'm happen to find out call Storage only do cleanup when new Entry comes and do nothing when entries get from storage. So entries will be next expired if there are only read activities.I agree with your analysis and solution. If you provide a test for the fix,I'll check it in. If you cannot write a test, please add least add an issueto the issue collector. Regards,Stephan--Stephan RichterCBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student)Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] (zope/app/cache/ram.py) class Storage's cleanup problem.
Dear all, I'm happen to find out call Storage only do cleanup when new Entry comes and do nothing when entries get from storage. So entries will be next expired if there are only read activities. So I suggest we may change the getEntry as below: def getEntry(self, ob, key): # start of insert if self.lastCleanup = time() - self.cleanupInterval: self.cleanup() # end of insert try: data = ""> except KeyError: if ob not in self._misses: self._misses[ob] = 0 self._misses[ob] += 1 raise else: data[2] += 1 # increment access count return data[0] Can somebody update this into the repository? Thanks, Simon ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com