class documentation

class LRUCache:

View In Hierarchy

A simple LRU Cache implementation.
Method __contains__ Check if a key exists in this cache.
Method __delitem__ Remove an item from the cache dict. Raise a KeyError if it does not exist.
Method __getitem__ Get an item from the cache. Moves the item up so that it has the highest priority then.
Method __getnewargs__ Undocumented
Method __getstate__ Undocumented
Method __init__ Undocumented
Method __iter__ Undocumented
Method __len__ Return the current size of the cache.
Method __repr__ Undocumented
Method __reversed__ Iterate over the keys in the cache dict, oldest items coming first.
Method __setitem__ Sets the value for an item. Moves the item up so that it has the highest priority then.
Method __setstate__ Undocumented
Method ​_postinit Undocumented
Method clear Clear the cache.
Method copy Return a shallow copy of the instance.
Method get Return an item from the cache dict or default
Method items Return a list of items.
Method keys Return a list of all keys ordered by most recent usage.
Method setdefault Set default if the key is not in the cache otherwise leave unchanged. Return the value of this key.
Method values Return a list of all values.
Instance Variable ​_append Undocumented
Instance Variable ​_mapping Undocumented
Instance Variable ​_pop Undocumented
Instance Variable ​_popleft Undocumented
Instance Variable ​_queue Undocumented
Instance Variable ​_remove Undocumented
Instance Variable ​_wlock Undocumented
Instance Variable capacity Undocumented
def __contains__(self, key):
Check if a key exists in this cache.
Parameters
key:t.AnyUndocumented
Returns
boolUndocumented
def __delitem__(self, key):
Remove an item from the cache dict. Raise a KeyError if it does not exist.
Parameters
key:t.AnyUndocumented
def __getitem__(self, key):

Get an item from the cache. Moves the item up so that it has the highest priority then.

Raise a KeyError if it does not exist.

Parameters
key:t.AnyUndocumented
Returns
t.AnyUndocumented
def __getnewargs__(self):

Undocumented

Returns
t.TupleUndocumented
def __getstate__(self):

Undocumented

Returns
t.Mapping[str, t.Any]Undocumented
def __init__(self, capacity):

Undocumented

Parameters
capacity:intUndocumented
def __iter__(self):

Undocumented

Returns
t.Iterator[t.Any]Undocumented
def __len__(self):
Return the current size of the cache.
Returns
intUndocumented
def __repr__(self):

Undocumented

Returns
strUndocumented
def __reversed__(self):
Iterate over the keys in the cache dict, oldest items coming first.
Returns
t.Iterator[t.Any]Undocumented
def __setitem__(self, key, value):
Sets the value for an item. Moves the item up so that it has the highest priority then.
Parameters
key:t.AnyUndocumented
value:t.AnyUndocumented
def __setstate__(self, d):

Undocumented

Parameters
d:t.Mapping[str, t.Any]Undocumented
def _postinit(self):

Undocumented

def clear(self):
Clear the cache.
def copy(self):
Return a shallow copy of the instance.
Returns
LRUCacheUndocumented
def get(self, key, default=None):
Return an item from the cache dict or default
Parameters
key:t.AnyUndocumented
default:t.AnyUndocumented
Returns
t.AnyUndocumented
def items(self):
Return a list of items.
Returns
t.Iterable[t.Tuple[t.Any, t.Any]]Undocumented
def keys(self):
Return a list of all keys ordered by most recent usage.
Returns
t.Iterable[t.Any]Undocumented
def setdefault(self, key, default=None):
Set default if the key is not in the cache otherwise leave unchanged. Return the value of this key.
Parameters
key:t.AnyUndocumented
default:t.AnyUndocumented
Returns
t.AnyUndocumented
def values(self):
Return a list of all values.
Returns
t.Iterable[t.Any]Undocumented
_append =

Undocumented

_mapping: t.Dict[t.Any, t.Any] =

Undocumented

_pop =

Undocumented

_popleft =

Undocumented

_queue: te.Deque[t.Any] =

Undocumented

_remove =

Undocumented

_wlock =

Undocumented

capacity =

Undocumented