Simple object-store caching helper library for python3. It uses Pickle for L2 cache and Minio as L3 cache.
Project description
Python-Minio-L3-Cache
Simple object-store caching helper library for python3. It uses Pickle for L2 cache and Minio as L3 cache.
Installation:
pip install Python-Minio-L3-Cache
Simple Usage:
from L3MinioCache import L2L3Cache
from minio import Minio
a = 'some variable'
client = Minio("url.com", "key", "secret")
cache = L2L3Cache('./tmp', client, 'test')
cache.dump('test', a)
new_a = cache.load('test')
Usage with callback wrapper will execute your method if cache misses in picke (l2) and minio (l3), and saves the file with the provided name and a hashed md5 string of the arguments and the source code of the method. Note that if methods called by the callback method are changed, this hash will not, therefore you should delete the old file in this case. Use relevant naming to avoid losing track of your files.
from L3MinioCache import L2L3Cache, L2L3HashedCache
from minio import Minio
a = 'some variable'
client = Minio("url.com", "key", "secret")
cache = L2L3Cache('./tmp', client, 'test')
def testfunc(a, b):
print('executed')
return a+b
cache_hashed = L2L3HashedCache(cache)
result = cache_hashed.execute('test2', testfunc, 1, 2)
The pickle (l2) cache file are appended a ".pickle" extension, therefore it is recommended you to add "*.pickle" to your .gitignore
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Python-Minio-L3-Cache-0.1.4.tar.gz
.
File metadata
- Download URL: Python-Minio-L3-Cache-0.1.4.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4374a8426ab480afbb404ce837311bfb1fb1ae68b5d46bb0a7fa2a80936b294 |
|
MD5 | 6a2b48c868d14e0ace073d36112abc8b |
|
BLAKE2b-256 | 217c9e1d111ffdd9ddd755abc52c676d890cf20be643fce40c82224644ea2706 |
File details
Details for the file Python_Minio_L3_Cache-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: Python_Minio_L3_Cache-0.1.4-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a76ca8b61373e7424ed84054a75a7cf56b51ae96f8ea64e1523a7a417f87249 |
|
MD5 | 1745371600e25594c451a0308dc850e9 |
|
BLAKE2b-256 | d153bdcd001036062210b832be4fd9ecfc5199cc08af4d793992a99908a064d6 |