Skip to content

v0.1.4 — caching (@Cacheable/@CacheEvict)

Choose a tag to compare

@zombocoder zombocoder released this 12 Jul 15:23
· 19 commits to main since this release

Adds annotation-driven caching (#32, PR #50).

Runtime

  • runtime.Cache (Get/Set/Delete with per-entry TTL) + MemoryCache, the in-process default wired into ProxyDependencies.

@Cacheable / @CacheEvict

On an interface-backed service method:

  • @Cacheable(key="user:#{id}", ttl="1m") — read-through: cached value on a hit (target skipped), stored on a miss. Method must return (T, error); value is JSON-serialized. Key #{param} placeholders resolve to method arguments.
  • @CacheEvict(key="…") — invalidates the entry after the method succeeds.

New module: adapters/redis (adapters/redis/v0.1.0)

runtime.Cache over redis/go-redis/v9 (WithPrefix, nil→miss, ttl 0 → no expiry). Install: go get github.com/zombocoder/goboot/adapters/redis@v0.1.0 (requires core v0.1.4).

Full coverage incl. an e2e proving hit-skips-target / evict-invalidates and a miniredis-backed adapter test.