LRU caches are nice and simple, but if you want something fancier, with support for squid-like expiry models (ie, using mtime and atime to estimate a "stale time", and IMS fetches), you can have a look at my GCache;
http://minkirri.apana.org.au/~abo/projects/GCache Even if you don't want something that fancy, it uses a PQueue priority queue to achieve exactly what you want. I provide a pure-python implementation using bisect, but recommend a C extension module with the same name by Andrew Snare which uses a fibonacci heap (python-pqueue is the Debian Package). Note that python 2.3 introduced a heapq module that does for queue lists what bisect does for heap lists. I am planning to modify my PQueue to use it instead of bisect. -- http://mail.python.org/mailman/listinfo/python-list