A powerfull python caching tool
Project description
PyCachera
A powerful python decorator to cache functions
Installation
In command line:
pip install pycachera
Usage
Import the pycachera as:
from pycachera import cache
For caching a function
@cache()
def sum(a,b):
return a+b
For caching a class attributes.
class Math:
def __init__(self):
pass
@cache()
def sum(a,b):
return a + b
For caching to a specific directory.
@cache(cachefolder='/home/user/scratch')
def sum(a,b):
return a+b
For caching with a specific key
@cache(cachekey='This a custom cache')
def sum(a,b):
return a+b
For printing the info
@cache(verbose=True)
def sum(a,b):
return a+b
While debugging your script if you want to ignore the cached values you can recache
@cache(recache=True)
def sum(a,b):
return a+b
When you use cache with a class attribute, and if you want to consider some attributes of that class for caching,
class Math:
def __init__(self,c):
self.c = c
@cache(extrarg=['c'])
def sum(a,b):
return a + b
To cache a class property,
class math:
def __init__(self,a,b):
self.a = a
self.b = b
@property
@cache(extrarg=['a','b'],verbose=True)
def add(self):
return self.a + self.b
API
visit pycachera.readthedocs.io
Project details
Release history Release notifications | RSS feed
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 pycachera-3.0.2.tar.gz
.
File metadata
- Download URL: pycachera-3.0.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1e77912293b7991a7afc788497f5472fd64739abbced2733dc89cec496c2538 |
|
MD5 | f3c7d5340bc71143196e370e367b86d3 |
|
BLAKE2b-256 | 732478566e80b64de01010298f7799cb3e274de35b68450205c2ea268ba9027e |
File details
Details for the file pycachera-3.0.2-py3-none-any.whl
.
File metadata
- Download URL: pycachera-3.0.2-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d82f09659b3b2b5ce25bc2edd3b1b5fabd41c923d421a3241b84b44069764e6 |
|
MD5 | 9f234e15fb9f4801963ac4a7cea09608 |
|
BLAKE2b-256 | 8d81791c9a62036a9218fb3ba876017a23bc75e8721bfafe1119d9a88bdffb85 |