Memoization function decorators using Amazon S3 for Python
Install
pip install s3-memoize
Usage
Setup AWS credentials (e.g. myprofile or default).
Make a S3 bucket (e.g. mybucketname).
Create test.py.
from functools import lru_cache
from s3_memoize import s3_fifo_cache, s3_lru_cache
BUCKET_NAME='mybucketname'
# @lru_cache(maxsize=2, typed=False)
@s3_fifo_cache(maxsize=2, typed=False, bucket_name=BUCKET_NAME)
# @s3_lru_cache(maxsize=2, typed=False, bucket_name=BUCKET_NAME)
def test(num):
print(f'test: {num}')
return num * 2
print(test.cache_clear())
# print(test.cache_set_expiration(days=1))
print(test.cache_info())
print(test(10))
print(test.cache_info())
print(test(10))
print(test.cache_info())
print(test(20))
print(test.cache_info())
print(test(20))
print(test.cache_info())
print(test(10))
print(test.cache_info())
print(test(30))
print(test.cache_info())
print(test(30))
print(test.cache_info())
Run. You can omit AWS_PROFILE if it’s default.
AWS_PROFILE=myprofile python test.py
Metadata
Release files for s3-memoize 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| s3_memoize-0.1.4.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| s3_memoize-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.8 kB
Release files / s3_memoize-0.1.4.tar.gz
| Download URL | s3_memoize-0.1.4.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d54af096343d4c1409e7045ee9258c83c7fcd24fec5ce12f885681356319aed
|
|
BLAKE2b-256 checksum How to use checksums |
e258461fd88489459cd46dc8db0b8cf671fc6681cb264204f9cdbdf1370c8adb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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.48.2 CPython/3.7.7
|
Release files / s3_memoize-0.1.4-py3-none-any.whl
| Download URL | s3_memoize-0.1.4-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44949305e1b767b87083939b4d45ba3edaa01b8e8b681343da517a274de77f6f
|
|
BLAKE2b-256 checksum How to use checksums |
e4153656741918dd0527dcf1218ffe6c0b5e17cdba46fa708ee79dd3a90a7ce2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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.48.2 CPython/3.7.7
|