class documentation
class LRUCache(Generic[
Known subclasses: dulwich.lru_cache.LRUSizeCache
Constructor: LRUCache(max_cache, after_cleanup_count)
A class which manages a cache of entries, removing unused ones.
| Method | __contains__ |
Check if key is in cache. |
| Method | __getitem__ |
Get item from cache and mark as recently used. |
| Method | __init__ |
Initialize LRUCache. |
| Method | __len__ |
Return number of items in cache. |
| Method | __setitem__ |
Add a value to the cache, there will be no cleanup function. |
| Method | add |
Add a new value to the cache. |
| Method | cache |
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 | get |
Get value from cache with default if not found. |
| Method | items |
Get the key:value pairs as a dict. |
| Method | keys |
Get the list of keys currently cached. |
| Method | resize |
Change the number of entries that will be cached. |
| Method | _record |
Record that key was accessed. |
| Method | _remove |
Remove one entry from the lru, and handle consequences. |
| Method | _remove |
Undocumented |
| Method | _update |
Undocumented |
| Method | _walk |
Walk the LRU list, only meant to be used in tests. |
| Instance Variable | _after |
Undocumented |
| Instance Variable | _cache |
Undocumented |
| Instance Variable | _least |
Undocumented |
| Instance Variable | _max |
Undocumented |
| Instance Variable | _most |
Undocumented |
overridden in
dulwich.lru_cache.LRUSizeCacheClear 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.
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.
Returns: An unordered list of keys that are currently cached.
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.