A Python decorator library for caching function results in MongoDB
Project description
A Python decorator library for instantly caching function results in MongoDB.
Basic Usage
from mongo_memoize import memoize
@memoize()
def func():
...
Customization
You can specify custom serializer and key_generator. serializer is used to serialize function results in order to convert them into formats that can be stored in MongoDB. key_generator generates a cache key from the function arguments. PickleSerializer and PickleMD5KeyGenerator are used by default.
from mongo_memoize import memoize, NoopSerializer, PickleMD5KeyGenerator
@memoize(serializer=NoopSerializer(), key_generator=PickleMD5KeyGenerator())
def func():
...
Using Capped Collection
Capped collection is a MongoDB feature which allows to limit the maximum size of the collection. By setting capped=True, a capped collection is created automatically.
from mongo_memoize import memoize
@memoize(capped=True, capped_size=100000000)
def func():
...
Documentation
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
File details
Details for the file mongo-memoize-0.0.3.tar.gz
.
File metadata
- Download URL: mongo-memoize-0.0.3.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a06fbd790f35bfd1555545d0faeab07601a08191332bb4731ca919af02ebee05 |
|
MD5 | 632a1e75d434e15469b5cd59155adbb0 |
|
BLAKE2b-256 | 49b3d59320a134742cef1a3d88d49eee03400f92920abcedfce8f2d1f2d9ea90 |