Skip to main content

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

Python-Minio-L3-Cache-0.1.4.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

Python_Minio_L3_Cache-0.1.4-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page