|
From: Eddie C. <ed...@ho...> - 2004-07-29 19:30:12
|
What is the best way to completely flush the cache for a particular class? I
have the following code but it seems ungainly.
for j in Job.select():
if 'Job' in j._connection.cache.caches:
for id in j._connection.cache.caches['Job'].allIDs():
j._connection.cache.caches['Job'].expire(id)
# j._connection.cache.caches['Job'].flush()
break
where Job is my SO class. I experimented with a method in CacheFactory called
flush() like so:
def flush(self):
self.lock.acquire()
for key, _ in self.cache.items():
del self.cache[key]
for key, _ in self.expiredCache.items():
del self.expiredCache[key]
self.lock.release()
which I think would be more efficient but is it correct? It certainly works
but I'm not sure if there's some dependency I've missed.
Also, while I was poking around in Cache.py I noticed that the expireAll()
method (whose function is inconsistent with the other expire() method in that
it doesn't completely remove data from both caches - just a minor naming
nitpick) has a bug in that obj is undefined, I assume it should be value.
I'll try and remember to submit this.
I'm using 0.5.2 since I assume that it's more stable. Is that true, if not,
why not just put it on the web page?
Also as well, the link on the web page entitled "Mostly Live CVS Tarball"
seems to be rather ancient!
Eddie
|