Known subclasses: dulwich.lru_cache.LRUSizeCache

A class which manages a cache of entries, removing unused ones.
Method __init__ Undocumented
Method __contains__ Undocumented
Method __getitem__ Undocumented
Method __len__ Undocumented
Method add Add a new value to the cache.
Method cache_size Get the number of entries we will cache.
Method get Undocumented
Method keys Get the list of keys currently cached.
Method items Get the key:value pairs as a dict.
Method cleanup Clear the cache until it shrinks to the requested size.
Method __setitem__ Add a value to the cache, there will be no cleanup function.
Method clear Clear out all of the cache.
Method resize Change the number of entries that will be cached.
Method _walk_lru Walk the LRU list, only meant to be used in tests.
Method _record_access Record that key was accessed.
Method _remove_node Undocumented
Method _remove_lru Remove one entry from the lru, and handle consequences.
Method _update_max_cache Undocumented
def __init__(self, max_cache=100, after_cleanup_count=None):
Undocumented
def __contains__(self, key):
Undocumented
def __getitem__(self, key):
Undocumented
def __len__(self):
Undocumented
def _walk_lru(self):
Walk the LRU list, only meant to be used in tests.
def add(self, key, value, cleanup=None):

Add a new value to the cache.

Also, if the entry is ever removed from the cache, call cleanup(key, value).

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 get(self, key, default=None):
Undocumented
def keys(self):

Get the list of keys currently cached.

Note that values returned here may not be available by the time you request them later. This is simply meant as a peak into the current state.

ReturnsAn unordered list of keys that are currently cached.
def items(self):
Get the key:value pairs as a dict.
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 __setitem__(self, key, value):
Add a value to the cache, there will be no cleanup function.
def _record_access(self, node):
Record that key was accessed.
def _remove_node(self, node):
Undocumented
def _remove_lru(self):

Remove one entry from the lru, and handle consequences.

If there are no more references to the lru, then this entry should be removed from the cache.

def clear(self):
Clear out all of the cache.
def resize(self, max_cache, after_cleanup_count=None):
Change the number of entries that will be cached.
def _update_max_cache(self, max_cache, after_cleanup_count=None):
Undocumented
API Documentation for Dulwich, generated by pydoctor at 2018-11-17 19:05:54.