Skip to main content

Unforgettable is a simple cache you can used for tiny repetitive executions.

Project description

Unforgettable - v0.1.1

Unforgettable is a simple cache class you can used for tiny repetitive executions.

It uses a temp dir for each execution.

How to install and use

Install with uv or pip

uv add unforgettable
# or
pip unforgettable

Setting values:

cache = unforgettable()

cache.set(content=code, cache_id=cache_id=cache_id)

Setting values:

cache = unforgettable()

cached_code = cache.get(cache_id=cache_id)

Using your own folder for storing longer term cache:

SIMPLE_CACHE_ROOT_DIR = os.getenv("SIMPLE_CACHE_ROOT_DIR", None)
cache = unforgettable(cache_folder=SIMPLE_CACHE_ROOT_DIR)

And you can clean the cache with:

unforgettable.clean()

Example of Usage

import requests
from unforgettable import unforgettable

cache = unforgettable()

def my_request():
    url = "https://github.com/bouli/unforgettable"

    url_request_1 = requests_get(url) #no cache yet
    url_request_2 = requests_get(url) #with cache

def requests_get(url):
    cached_code = cache.get(cache_id=url)

    if cached_code is not None:
        print("You are using cached")
        return cached_code

    req = requests.get(url=url, timeout=5)
    if req.status_code != 200:
        return None

    code = req.content
    cache.set(content=code, cache_id=url)
    return code

See Also

License

This package is distributed under the MIT license.

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

unforgettable-0.1.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

unforgettable-0.1.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file unforgettable-0.1.1.tar.gz.

File metadata

  • Download URL: unforgettable-0.1.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for unforgettable-0.1.1.tar.gz
Algorithm Hash digest
SHA256 744e4da20bd721d8661a41dc3bf6c5f913731c01a2ceb75526723ca32e0b292e
MD5 41578f9de53cf87d0194dee79f92f8ee
BLAKE2b-256 bfd74775c26ded0118757ded8bf65d95a25a296da8e4fe0e6b4072bec0bf2853

See more details on using hashes here.

File details

Details for the file unforgettable-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: unforgettable-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for unforgettable-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 da2a1b517db204167023215df8ac03cba263b21461544b1c9ba16ddb69e9c6dc
MD5 fc0e48e82946fd1cb7a4262781e9bbba
BLAKE2b-256 c11dbfd30ccddf099fc36fdd4445198dc74887e471f31d336ee12c41753ee288

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