Implementing a cache

skip at pobox.com skip at pobox.com
Sun Jul 12 15:01:23 CEST 2009


    Nikolaus> I want to implement a caching data structure in Python that
    Nikolaus> allows me to:

    Nikolaus>  1. Quickly look up objects using a key
    Nikolaus>  2. Keep track of the order in which the objects are accessed
    Nikolaus>     (most recently and least recently accessed one, not a
    Nikolaus>     complete history)
    Nikolaus>  3. Quickly retrieve and remove the least recently accessed
    Nikolaus>     object.

My Cache module does #1 and #3.  I'm not sure if you want #2 for internal
cache maintenance or for as part of the API.

    http://www.smontanaro.net/python/Cache.py

Skip



More information about the Python-list mailing list