| Home | Trees | Indices | Help | 
 | 
|---|
|  | 
object --+    
         |    
      dict --+
             |
            LRUCache
A dictionary-like object that stores only a certain number of items, and discards its least recently used item when full.
>>> cache = LRUCache(3) >>> cache['A'] = 0 >>> cache['B'] = 1 >>> cache['C'] = 2 >>> len(cache) 3
>>> cache['A'] 0
Adding new items to the cache does not increase its size. Instead, the least recently used item is dropped:
>>> cache['D'] = 3 >>> len(cache) 3 >>> 'B' in cache False
Iterating over the cache returns the keys, starting with the most recently used:
>>> for key in cache: ... print(key) D A C
This code is based on the LRUCache class from myghtyutils.util, written by Mike Bayer and released under the MIT license. See:
http://svn.myghty.org/myghtyutils/trunk/lib/myghtyutils/util.py
| Instance Methods | |||
| new empty dictionary | 
 | ||
| True if D has a key k, else False | 
 | ||
| 
 | |||
| 
 | |||
| 
 | |||
| 
 | |||
| 
 | |||
| Inherited from  Inherited from  | |||
| Class Variables | |
| Inherited from  | 
| Properties | |
| Inherited from  | 
| Method Details | 
| 
 
 | 
| 
 
 | 
| 
 
 | 
| 
 
 | 
| 
 
 | 
| 
 
 | 
| 
 
 | 
| Home | Trees | Indices | Help | 
 | 
|---|
| Generated by Epydoc 3.0.1 on Sun Jan 27 18:17:20 2013 | http://epydoc.sourceforge.net |