redis-cache

command
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 13 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL