skillfed

repoze-lru

A tiny LRU cache implementation and decorator

repoze-lru v0.8 3.2M downloads/30d#2,705 on PyPI105
Permissive license LicenseRef-Repoze-BSD-derived Active released

What it is and what it does

repoze.lru is a standalone LRU cache implementation designed to automatically manage memory by evicting the least recently used entries when the cache reaches its size limit. It provides both a decorator and a direct cache class interface, making it suitable for caching expensive function results or storing frequently accessed data.

The package has been maintained since 2009 and is classified as mature. It carries no runtime dependencies, making it lightweight and easy to integrate into existing projects. The implementation supports modern Python versions and is actively maintained, with recent updates confirming ongoing compatibility.

Use it for:

  • Decorate expensive database query functions to avoid repeated lookups with the same parameters.
  • Cache API responses in web applications to reduce external service calls.
  • Store computed results in data processing pipelines to speed up repeated calculations.
  • Implement session or token caching in WSGI middleware applications.
  • Reduce memory usage in long-running processes by automatically evicting stale cached data.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A lightweight LRU (least recently used) cache implementation that evicts infrequently accessed keys and values to manage memory automatically.

Yes. This is a mature, dependency-free caching utility with active maintenance, permissive licensing, and no known vulnerabilities. Install it if you need a simple, lightweight LRU cache without the overhead of external dependencies or more complex caching frameworks. It is particularly suited to WSGI and web applications.

Install

repoze-lru on PyPI

pip

pip install repoze-lru

uv

uv add repoze-lru

poetry

poetry add repoze-lru

Installing repoze-lru

Before you install

Low friction install with no runtime dependencies. Actively maintained, last release within 90 days, repository not archived, and supports current Python versions.

License in practice

Licensed under a permissive Repoze BSD-derived license, allowing use in most projects without significant legal constraints.

Quickstart

pip install repoze-lru

from repoze.lru import lru_cache

@lru_cache()
def cached_function(x):
    return x * 2

Requires Python 3.10 or later.

Verify before relying

  • Whether the cache is thread-safe for concurrent access patterns.
  • Performance characteristics compared to standard library alternatives.
  • Memory overhead per cached entry and eviction behavior under load.
  • Specific maxsize parameter defaults and tuning guidance.

Package facts

License LicenseRef-Repoze-BSD-derived (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 90 days since the last release
Last repo commit
First released
Downloads 3,200,599/month — #2,705 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: repoze_lru-0.8-py3-none-any.whl

Keywords: repoze, lru, cache

Development Status :: 6 - MatureIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: WSGITopic :: Internet :: WWW/HTTP :: WSGI :: Middleware

Tags

lru cache pythonleast recently used cachein-memory cache evictioncache decoratormemory-efficient cachingrepoze lrusimple cache implementation
cachingperformance-optimizationwsgi

More WWW/HTTP packages