Registry / database / moka-py

moka-py

JSON →
library0.3.0pypypi✓ verified 80d ago

A high performance caching library for Python, written in Rust with PyO3. Provides a concurrent hashmap cache with TTL, TTI, size-based eviction, and a decorator for async/sync functions. Current version 0.3.0, actively maintained, monthly releases.

pip install moka-py
INSTALL
IMPORT
SIG · MOKA-PY
M
moka-py
databasepythonv0.3.0
Install
1.7s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Moka
from moka_py import Moka
from moka import Cache
cached
from moka_py import cached
from moka import cached
VERSION
from moka_py import VERSION
from moka import VERSION

Create a cache with max 100 entries and 5-minute TTL.

from moka import Cache cache = Cache(max_capacity=100, time_to_live_seconds=300) cache.insert('key', 'value') print(cache.get('key'))
Debug
Known issues
gotchaThe Cache is concurrent and thread-safe, but `get` returns None if the key is missing or expired. Do not assume a key exists after insertion without checking.
fix
Use cache.get('key') and handle None, or use cache.get_or_insert('key', default_value).
affects: all
gotchaThe `@cached` decorator for async functions requires `wait_concurrent=True` in versions <0.2.1; from 0.2.1+ it is the default for async functions.
fix
Update to >=0.2.1 or pass `wait_concurrent=True` explicitly.
affects: <0.2.1
deprecatedThe `remove` method's `default` parameter (introduced in 0.1.15) may be removed in future versions. Use `pop` instead.
fix
Use `cache.pop(key, default=None)` instead of `cache.remove(key, default=None)`.
affects: >=0.1.15
Upgrade
Version history
0.3.0latest on PyPI · released Feb 3, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources