Skip to main content

Memoization function decorators using Amazon S3 for Python

Project description

Memoization function decorators using Amazon S3 for Python

Install

pip install s3-memoize

Usage

Setup AWS credentials (e.g. myprofile).

Make a S3 bucket (e.g. mybucketname).

Make test.py.

from s3_memoize import s3_fifo_cache, s3_lru_cache

BUCKET_NAME='mybucketname'

@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_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.

AWS_PROFILE=myprofile python test.py

Author

Susumu OTA

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

s3_memoize-0.1.3.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

s3_memoize-0.1.3-py3-none-any.whl (9.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