Unforgettable is a simple cache you can used for tiny repetitive executions.
Project description
Unforgettable - v0.1.0
Unforgettable is a simple cache class you can used for tiny repetitive executions.
It uses a temp dir for each
execution. But you can define a your own directory and use the cache as much as
you want setting SIMPLE_CACHE_ROOT_DIR env var.
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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unforgettable-0.1.0.tar.gz.
File metadata
- Download URL: unforgettable-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1f01d6ab903b6c883b8196e76d5fbe28109179dafc3e1fab1da62de99fe794c
|
|
| MD5 |
c998575a529c84e2245d19957a360490
|
|
| BLAKE2b-256 |
52388898214fa2549fd940668f6c6c530778d21135b15a6d2d77d348c7768039
|
File details
Details for the file unforgettable-0.1.0-py3-none-any.whl.
File metadata
- Download URL: unforgettable-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6ea7d967e5c38c8ea4bbf2eeb1aa0e1865e67b42de051efceccd6e1b72235e5
|
|
| MD5 |
f06d93ef2cdb2d1524d6929f710e5259
|
|
| BLAKE2b-256 |
9ddcc44011eed98818ad99948c92620c0e341fd59d3529dc5e81163ee0d562ea
|