Skip to main content
PyPI - License Pipeline status Test code coverage Benchmark PyPI RTFM

HermesCache

Hermes is a Python caching library. It was designed to fulfil the following requirements:

  • Tag-based O(1) cache invalidation

  • Dogpile effect (cache stampede) mitigation

  • Support for multi-threaded, multi-process, multi-machine & asynchronous operation

  • Cache compression

  • Modular design (pluggable backends, compressors, serialisers, etc.)

  • Simple yet flexible decorator API

Implemented backends: redis, memcached, inprocess.

Installation

pip install HermesCache

For Redis (or protocol-compatible alternatives) and Memcached it has the following extra dependencies.

HermesCache[redis]

Pure Python Redis client

HermesCache[redis-ext]

Pure Python Redis client & C extension parser

HermesCache[memcached]

Pure Python Memcached client

Quickstart

The following demonstrates the most of the package’s API.

import hermes.backend.redis


cache = hermes.Hermes(
  hermes.backend.redis.Backend,
  ttl = 600,
  host = 'localhost',
  db = 1,
)

@cache
def foo(a, b):
  return a * b

class Example:

  @cache(tags = ('math', 'power'), ttl = 1200)
  def bar(self, a, b):
    return a ** b

  @cache(tags = ('math', 'avg'), key = lambda fn, a, b: f'avg:{a}:{b}')
  def baz(self, a, b):
    return (a + b) / 2

print(foo(2, 333))

example = Example()
print(example.bar(2, 10))
print(example.baz(2, 10))

foo.invalidate(2, 333)
example.bar.invalidate(2, 10)
example.baz.invalidate(2, 10)

cache.clean(['math']) # invalidate entries tagged 'math'
cache.clean()         # flush cache

Metadata

Release files for HermesCache 1.2.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 HermesCache 1.2.0
File Size Uploaded Provenance Actions
hermescache-1.2.0.tar.gz 25.0 kB Without provenance Details for hermescache-1.2.0.tar.gz

Release files / hermescache-1.2.0.tar.gz

Download URL hermescache-1.2.0.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2ffb4c110202993cf1dddee577343c9c6cb5727cf96051d59965a45e2bf08efd
BLAKE2b-256 checksum
How to use checksums
a05f3097d9d98d83acb8f97d3db99e5b3ab1c93271aa81fa9aec33204b1d06bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for HermesCache 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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