Skip to main content

cacheing - Pure Python Cacheing Library

Coverage


Motivation


The initial motivation behind this package was twofold: fix the long insertion/eviction times in cachetools.LFUCache and provide an alternative to the cachetools.TTLCache offering variable per-key TTL's.

Installation


pip install -U cacheing

And then in your python interpreter:

import cacheing

Updating


Usage


>>> from cacheing import LFUCache

>>> cache = LFUCache(capacity=2)

>>> cache[1] = 2
>>> cache[2] = 3
>>> cache[3] = 4

>>> cache
LFUCache{2: 3, 3: 4}

Benchmark


cacheing has an included benchmarking library found in ./benchmark.

$ python3 ./benchmark.py --help

usage: benchmark [-h] [--cache [CACHE [CACHE ...]]] [--method [{get,set,delete} [{get,set,delete} ...]]]

arguments:
  -h, --help            show this help message and exit
  --cache [CACHE [CACHE ...]], -c [CACHE [CACHE ...]]
                        cache(s) to benchmark. example: cacheing.LRUCache.
  --method [{get,set,delete} [{get,set,delete} ...]], -m [{get,set,delete} [{get,set,delete} ...]]
                        method(s) to benchmark.

Run the Benchmarks:

$ cd benchmark

$ python3 ./benchmark.py --cache cachetools.LRUCache cacheing.LRUCache --method set get delete

Performance


All benchmark times were measured using the provided benchmark library. See the benchmark section for details. The default benchmarking configuration executes 100,000 get operations, 20,000 set operations and n = cache_size delete operations. The median, p90, and p99 times for each operation, measured in microseconds, or 1e-6, are displayed in the figures below.


Get (LFU Cache)             Delete (LFU Cache)

Set (LFU Cache)             Set - Cross Section (LFU Cache)


Set (LRU Cache)             Get (LRU Cache)

Delete (LRU Cache)

Metadata

Release files for cacheing 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cacheing 0.1.1
File Size Uploaded
cacheing-0.1.1.tar.gz 11.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cacheing 0.1.1
File Interpreter ABI Platform
cacheing-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.7 kB

Release files / cacheing-0.1.1.tar.gz

Download URL cacheing-0.1.1.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eb83d67c5d7af5364f1a338da2c5cf26b4623c5f5670bd2a61ee93123d1b00c2
BLAKE2b-256 checksum
How to use checksums
1e5a3dcf8f1a3b6fcbdebcb3f3b94082973ec0384d40bfcd3d59dcec17991dca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.3 Windows/10

Release files / cacheing-0.1.1-py3-none-any.whl

Download URL cacheing-0.1.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3719f9d5c2a846ed2839d65a76c4bd5bd4c440fa37d92af998545a7fa571ee3f
BLAKE2b-256 checksum
How to use checksums
d2c8c8d8668700b51dd99dfda012f3ba0fd013ff685f8a6665ecff3b61f12fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.3 Windows/10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page