a (more) general cache facility that is safe(r) memory-wise

David Allouche david at allouche.net
Sat Feb 4 17:16:07 GMT 2006


On Mon, 2006-01-16 at 01:56 +0100, Denys Duchier wrote:
> cache.put(val) returns a "reference" to the value (like a weakref).  You can
> test whether the reference is still valid with:
> 
> 	ref.alive
> 
> in which case you can retrieve the cached value with:
> 
> 	ref.value
> 
> --Denys

Isn't that a racy API?

There should not be different APIs for testing liveliness and retrieving
cache entries when cache expiration is tied to the garbage collector.

The weakref documentation covers the issue:
http://python.org/doc/2.4.2/lib/weakref-objects.html

-- 
                                                            -- ddaa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060204/e972220d/attachment.pgp 


More information about the bazaar mailing list