Skip to main content

LRU Cache

PyPI - Status Downloads codecov

LRUCache is a Python package for in-memory caching using the LRU (Least Recently Used) eviction policy. Unlike Python’s built-in OrderedDict-based approach, this implementation uses a min-heap priority queue to track access times, providing efficient eviction of the least recently used entry when the cache reaches capacity.

Features

  • Zero dependencies with pure Python, no external libraries
  • Granular TTL (time-to-live) expiration per cache entry
  • Optional thread-safe mode via threading.RLock
  • Cache introspection methods: inspect capacity, TTL, and contents at runtime
  • Decorator-based caching for function return values

Usage

LRUCache only works in Python version 3.10 and above, you can install it with :

pip install lruheap

or, with uv package manager to faster installation :

uv pip install lruheap

Documentation

You can read the fully detailed explanation about this package in here

Contribution

Any contributions are much welcomed, and you can read on contribution page on how to contribute.

License

This package is licensed under the MIT License.

Release files for lruheap 1.3.0

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

Source distribution (sdist)

Source distribution for lruheap 1.3.0
File Size Uploaded
lruheap-1.3.0.tar.gz 13.4 kB Details

Built distribution (wheel)

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

Total release size: 23.0 kB

Release files / lruheap-1.3.0.tar.gz

Download URL lruheap-1.3.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
76043e3d3f0cc64b278ce63c56290748aeeb3a0735751a37d8fdb0f9d64d38a7
BLAKE2b-256 checksum
How to use checksums
e3c24f7f6e283f111da07101734c0ce568f56f7ec37fbbf5653a39ddefe73fea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / lruheap-1.3.0-py3-none-any.whl

Download URL lruheap-1.3.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ec7845763a75d56c3ab1ea7f2d2c34663a1698b98b7b6043e0aafff23a034da
BLAKE2b-256 checksum
How to use checksums
a7c8bd66ad44a69fb236d3dae58342a753d803a900c6646525fc942a7a6cd355
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

1.3.1

2 release files

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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