Skip to content

feat: support unhashable arguments in cache key generation #75

@27Bslash6

Description

@27Bslash6

Description

Competitive testing confirms cachekit handles unhashable arguments (lists, dicts, nested structures) that crash lru_cache and cachetools. This is a genuine competitive advantage worth highlighting.

Evidence

# lru_cache — crashes
@lru_cache(maxsize=128)
def fn(data): return sum(data)
fn([1, 2, 3])  # TypeError: unhashable type: 'list'

# cachetools — crashes
@cached(cache=TTLCache(maxsize=128, ttl=300))
def fn(data): return sum(data)
fn([1, 2, 3])  # TypeError: unhashable type: 'list'

# cachekit — works
@cache(backend=None, ttl=300)
def fn(data): return sum(data)
fn([1, 2, 3])  # 6 ✓
fn({"value": 21})  # works via content-based hashing ✓
fn({"users": [{"name": "alice", "tags": ["admin"]}]})  # nested ✓

Current State

This already works via content-based hashing (Blake2b of MessagePack-serialized args). However:

  1. It's not prominently documented as a feature
  2. The comparison doc doesn't call it out as an advantage
  3. There are no docs explaining HOW it works (content-based hashing)

Suggested Actions

  1. Add "Unhashable Arguments" section to comparison.md
  2. Document content-based key generation in backends/index.md
  3. Add examples to getting-started.md showing dict/list args

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions