lru od
0.0.1
Python Implémentation de LRU-CACH Utilisation d' OrderedDict
Python 3.7 ou plus requis!
Pour installer la version stable de la bibliothèque:
# on linux/macOS
python3 -m pip install lru-od
# windows
py -3 -m pip install lru-odPour installer la version de développement de la bibliothèque:
$ git clone https://github.com/XiehCanCode/lru-od
$ cd lru-od
$ python3 -m pip install -U . from lru import LRUCache
cache : LRUCache [ str , str ] = LRUCache ( max_size = 2 )
cache . set ( "foo" , "bar" ) # you can also use: cache['foo'] = 'bar'
cache . set ( "bar" , "foo" )
print ( cache . get ( "foo" )) # this key-pair would be pushed to end
cache . set ( "ping" , "pong" ) # since we're exceeding the max size, the least used will be removed, in this case it's {'bar': 'foo'} classe Lrucache
Implémentation du cache LRU
max_size: facultatif [ int ]
Taille maximale du cache, par défaut est à 120
x == y
x != y
x in y
key donnée sikey si existekey et pair donnés et renvoie la paire de valeurs de clé créée / mise à jour