LRU Cache
This is a simple Least Recently Used (LRU) Cache with expiration time that use redis to store the data.
Installation
Usage
Import LRUCache from the lru_redis_cache module, when creating an instance of this class you could pass:
cache_size: Max size of the cache, the default value is 10ttl: Max time to expire the cache, the default value is 60 secondsredis_host: Host where the redis instance is allocated, default is localhostredis_port: Redis port, default is 6379
This class has three public methods to manage the cache:
-
set(name, value)this function set a new cache value or replace the previous. -
get(name)this function return the cache element if it is stores, otherwise it will return aNonevalue. -
set_connection(RedisConnection)this function allows you to set the redis instance to be used.
from lru_redis_cache import LRUCache
cache = LRUCache(cache_size=5, ttl=60)
cache.set("my_key", "my_value")
cache.get("my_key")
# Output
"my_value"
Tests
In order to run the test cases you need to install the basic requirements from requirements.txt by running the following command.
pip install -r requirements.txt
Then, you need to run
python -m pytest
Information
Metadata
Release files for lru-redis-cache 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lru_redis_cache-0.1.tar.gz | 2.8 kB | Without provenance | Details for lru_redis_cache-0.1.tar.gz |
Release files / lru_redis_cache-0.1.tar.gz
| Download URL | lru_redis_cache-0.1.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89242997b9a12eacdd4d97f6d33df0592c85ac7a83b23b5c287edc6e82094a27
|
|
BLAKE2b-256 checksum How to use checksums |
3c0aadca2374852012bd5b26946785f600ed0d9caf9a76d54067816d99ce12c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5
|
Security for lru-redis-cache 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.