Skip to main content

cache functions output with auto refresh everytime you call it

Project description

functions cache

This library is inspired by requests-cache https://github.com/reclosedev/requests-cache and the whole engines code has been copied and modified from there.

this library provide a decorator that can be used to decorate your functions to be cached.

The main feature that diffentiate this library is that it will auto refresh the cache in a background thread so your cache will be kept fresh.

Sample code

from functions_cache import cache_it
import datetime



@cache_it
def fab_cached(n):
    if n < 2:
        return n
    else:
        return fab_cached(n-2)+fab_cached(n-1)

if __name__ == "__main__":
    t1 = datetime.datetime.now()
    print(fab_cached(100))
    t2 = datetime.datetime.now()
    print(t2-t1)
    t3 = datetime.datetime.now()
    print(fab_cached(100))
    t4 = datetime.datetime.now()
    print(t4-t3)
    

and the output

354224848179261915075
0:00:03.366472
354224848179261915075
0:00:00.014370

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

functions-cache-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

functions_cache-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file functions-cache-0.1.0.tar.gz.

File metadata

  • Download URL: functions-cache-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.5 Linux/5.8.0-50-generic

File hashes

Hashes for functions-cache-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2d464a7361b0e410992faddafe4bb54d617ed63107d73f7fbfae3e9f1db1e4e4
MD5 463e89e77fe547328825e55c63cbe8a5
BLAKE2b-256 4cb08d93268845987ff4594c6f4b6ffb63af6ff69c448524a475265b87215f4d

See more details on using hashes here.

File details

Details for the file functions_cache-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: functions_cache-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.5 Linux/5.8.0-50-generic

File hashes

Hashes for functions_cache-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a19b50157e3b9b96af5882ef57515c86b4e828e126bfa14ce03423db6af2a643
MD5 6fa4f80a6b3afffa137d74969882beef
BLAKE2b-256 7e729760fe5ccba5d461998ff41160e69311a5942ae9b9a475292dc3124bd88b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page