Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Decorator to wrap a function with a memoizing callable that has TTL result

Project description

ttl-cache

How to use it

pip install ttl-cache
import ttl_cache


# use ttl_cache directly
@ttl_cache
def expensive_operation(a, b):
    ...
    ...
    return SOME_RESULT

expensive_operation(xx, yy)
expensive_operation(xx, yy)  # prefer cached result
# ... 60 seconds later
expensive_operation(xx, yy)  # compute again


# or
@ttl_cache(2.0)  # cache the result in the next 2 seconds, default is 60.0 seconds
def expensive_operation(a, b):
    ...
    ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ttl-cache, version 1.5
Filename, size File type Python version Upload date Hashes
Filename, size ttl-cache-1.5.tar.gz (2.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page