lru od
0.0.1
Implementación de Python de LRU-Cache utilizando OrderedDict
Python 3.7 o más alto requerido!
Para instalar la versión estable de la biblioteca:
# on linux/macOS
python3 -m pip install lru-od
# windows
py -3 -m pip install lru-odPara instalar la versión de desarrollo de la biblioteca:
$ 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'} clase Lrucache
Implementación de caché de LRU
max_size: opcional [ int ]
Tamaño máximo del caché, predeterminado es a 120
x == y
x != y
x in y
key dada si existekey si existekey y pair dado y devuelve el par de valores de tecla creado/actualizado