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

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 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.0.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.0.0
File Size Uploaded
HermesCache-1.0.0.tar.gz 24.5 kB Details

Release files / HermesCache-1.0.0.tar.gz

Download URL HermesCache-1.0.0.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fa79dde04d1295176805c0fd2c146ce5c374a10700328b04c3d6b402b3e576ab
BLAKE2b-256 checksum
How to use checksums
46892bb807d45052e3ec63af6d38c8a01ee5760711c9184165688fb3d850c877
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

1.2.0

1 release file

1.1.0

1 release file

This release

1.0.0 This release

1 release file

0.10.0

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.5

1 release file

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