Part of bzrlib.fifo_cache View In Hierarchy
This differs in that it doesn't care how many actual items there are, it restricts the cache to be cleaned based on the size of the data.
Method | __init__ | Create a new FIFOSizeCache. |
Method | add | Add a new value to the cache. |
Method | cache_size | Get the number of bytes we will cache. |
Method | cleanup | Clear the cache until it shrinks to the requested size. |
Method | resize | Increase/decrease the amount of cached data. |
Method | _remove | Remove an entry, making sure to maintain the invariants. |
Inherited from FIFOCache:
Method | __setitem__ | Add a value to the cache, there will be no cleanup function. |
Method | __delitem__ | Undocumented |
Method | clear | Clear out all of the cache. |
Method | copy | Undocumented |
Method | pop | Undocumented |
Method | popitem | Undocumented |
Method | setdefault | similar to dict.setdefault |
Method | update | Similar to dict.update() |
Method | _remove_oldest | Remove the oldest entry. |
Parameters | max_size | The max number of bytes to store before we start clearing out entries. |
after_cleanup_size | After cleaning up, shrink everything to this size (defaults to 80% of max_size). | |
compute_size | A function to compute the size of a value. If not supplied we default to 'len'. |
Also, if the entry is ever removed from the queue, call cleanup. Passing it the key and value being removed.
Parameters | key | The key to store it under |
value | The object to store, this value by itself is >= after_cleanup_size, then we will not store it at all. | |
cleanup | None or a function taking (key, value) to indicate 'value' sohuld be cleaned up. |
This does not completely wipe the cache, just makes sure it is under the after_cleanup_size.
Parameters | max_size | The maximum number of bytes to cache. |
after_cleanup_size | After cleanup, we should have at most this many bytes cached. This defaults to 80% of max_size. |