Generic TTL + LRU in-memory cache with a small Store[V] interface.
- Type-safe generic cache values
- TTL expiration and background cleanup
- LRU eviction with a configurable max entry cap
- Atomic integer counters
- Key validation for CRLF, null bytes, empty strings, and length limits
cp -r registry/cache/src/go/*.go yourproject/internal/cache/Or with the Scion CLI:
scion add cache --to internal/cachec := cache.New[string](cache.WithMaxEntries(1000))
defer c.Close()
_ = c.Set(ctx, "user:123", "Ada", 5*time.Minute)
value, ok := c.Get(ctx, "user:123")
_ = value
_ = ok| File | Purpose |
|---|---|
store.go |
Store interface, key validation, entry and LRU primitives |
memory.go |
Concurrency-safe in-memory implementation |
pentest_test.go |
Security and abuse-case tests |
cd registry/cache/src/go
go test -v ./...