Skip to main content

A small, simple LRU cache

Project description

Welcome to Laroux

build CodeQL Code style: black PyPI PyPI - Python Version License

Laroux is a simple, friendly LRU cache written in Python.

An LRU cache, or least-recently-used cache, stores items based on recency of access, and the least recently used items will be removed from the cache when new items are added. Laroux defaults to a 32-member cache, but you may set the size of the cache as desired when using it:

from your_code import Document
from laroux import LarouxCache

class Server:
  def __init__(self):
    self.cache = LarouxCache[str, Document](100)
    self.port = 80

  def serve(url: str) -> Document:
    if self.cache.get(url) is not None:
      return self.cache[url]
    else:
      doc = fetch(url)
      self.cache.push(url, doc)
      return doc

Using an LRU cache is a reasonable and easy way to improve the performance of your Web application by running it in the server used on your load balancer. As with all caching, experimentation is encouraged and you may need to tweak Laroux slightly to better suit your needs. If you've made a change to Laroux that you think would be beneficial, don't hesitate to submit a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

laroux-0.1.1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

laroux-0.1.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file laroux-0.1.1.tar.gz.

File metadata

  • Download URL: laroux-0.1.1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for laroux-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bbdec1b1718de0cb84aaddf240e964afa0b69b8e539841272153809e2d5e2697
MD5 09a772b9d06f1d61a76ed61e8c694b6a
BLAKE2b-256 f0a15f51c7ed8221ff2c55e1bced1b79bc85b4e82e825ae85f27e3609fc36f43

See more details on using hashes here.

File details

Details for the file laroux-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: laroux-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for laroux-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15c52f2f8cdb51eb4dc71852390f858a40487d48ba6bce8ac4a499824d2ad8a4
MD5 56b0f14b898ba441ddf434765cd1f0fc
BLAKE2b-256 780bd330f4d5f702efb897e9fe637a7e79993e28543757745d49db7f3387d54f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page