b.f.FIFOCache(dict) : class documentation

Part of bzrlib.fifo_cache View In Hierarchy

Known subclasses: bzrlib.fifo_cache.FIFOSizeCache

A class which manages a cache of entries, removing old ones.
Method __init__ Undocumented
Method __setitem__ Add a value to the cache, there will be no cleanup function.
Method __delitem__ Undocumented
Method add Add a new value to the cache.
Method cache_size Get the number of entries we will cache.
Method cleanup Clear the cache until it shrinks to the requested size.
Method clear Clear out all of the cache.
Method resize Increase/decrease the number of cached entries.
Method copy Undocumented
Method pop Undocumented
Method popitem Undocumented
Method setdefault similar to dict.setdefault
Method update Similar to dict.update()
Method _remove Remove an entry, making sure to call any cleanup function.
Method _remove_oldest Remove the oldest entry.
def __init__(self, max_cache=100, after_cleanup_count=None):
Undocumented
def __setitem__(self, key, value):
Add a value to the cache, there will be no cleanup function.
def __delitem__(self, key):
Undocumented
def add(self, key, value, cleanup=None):
Add a new value to the cache.

Also, if the entry is ever removed from the queue, call cleanup. Passing it the key and value being removed.

ParameterskeyThe key to store it under
valueThe object to store
cleanupNone or a function taking (key, value) to indicate 'value' should be cleaned up
def cache_size(self):
Get the number of entries we will cache.
def cleanup(self):
Clear the cache until it shrinks to the requested size.

This does not completely wipe the cache, just makes sure it is under the after_cleanup_count.

def clear(self):
Clear out all of the cache.
def _remove(self, key):
Remove an entry, making sure to call any cleanup function.
def _remove_oldest(self):
Remove the oldest entry.
def resize(self, max_cache, after_cleanup_count=None):
Increase/decrease the number of cached entries.
Parametersmax_cacheThe maximum number of entries to cache.
after_cleanup_countAfter cleanup, we should have at most this many entries. This defaults to 80% of max_cache.
def copy(self):
Undocumented
def pop(self, key, default=None):
Undocumented
def popitem(self):
Undocumented
def setdefault(self, key, defaultval=None):
similar to dict.setdefault
def update(self, *args, **kwargs):
Similar to dict.update()
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.