Documentation
¶
Overview ¶
Package redis-cache demonstrates the typed cache boundary of adapters/redis: an IOPort declared with a CachePattern, a read-through GetAdapter, a write-through SetAdapter, the standalone Get/Set plain functions (no ports.IOAdapter, no stream — the non-pipeline entrypoint GetAdapter/SetAdapter delegate to), a per-key-variable codec (CacheKeyParam) rejecting a malformed key var, the Seed warm-restart helper, and the standalone ports.NewCache constructor (no port/pipeline involved).
Why a fake client? ¶
All adapter constructors accept the narrow redis.Commands interface, never a concrete client — so this example runs WITHOUT a Redis server, using the same in-memory fake style as the unit tests. In production, construct the client once and wrap it:
client := redis.NewCommands(goredis.NewUniversalClient(&goredis.UniversalOptions{
Addrs: []string{"localhost:6379"},
}))
Running ¶
go run ./examples/redis-cache