{"id":24063,"library":"moka-py","title":"moka-py","description":"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.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/deliro/moka-py","tags":["cache","rust","concurrent","ttl","high-performance"],"install":[{"cmd":"pip install moka-py","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Cache","correct":"from moka import Cache"}],"quickstart":{"code":"from moka import Cache\n\ncache = Cache(max_capacity=100, time_to_live_seconds=300)\ncache.insert('key', 'value')\nprint(cache.get('key'))","lang":"python","description":"Create a cache with max 100 entries and 5-minute TTL."},"warnings":[{"fix":"Use cache.get('key') and handle None, or use cache.get_or_insert('key', default_value).","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Update to >=0.2.1 or pass `wait_concurrent=True` explicitly.","message":"The `@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.","severity":"gotcha","affected_versions":"<0.2.1"},{"fix":"Use `cache.pop(key, default=None)` instead of `cache.remove(key, default=None)`.","message":"The `remove` method's `default` parameter (introduced in 0.1.15) may be removed in future versions. Use `pop` instead.","severity":"deprecated","affected_versions":">=0.1.15"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install --upgrade moka-py` and verify version >=0.1.0.","cause":"moka-py may not be installed, or you are using an older version without the `Cache` export.","error":"ImportError: cannot import name 'Cache' from 'moka'"},{"fix":"Check the return value for None before subscripting, or use `cache.get'with a default: `cache.get(key, 'default')`.","cause":"Cache.get() returned None because the key does not exist or expired.","error":"TypeError: 'NoneType' object is not subscriptable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}