Documentation
¶
Overview ¶
Package valkey is a Valkey (Redis protocol) connection as a dependency: a configuration section, a client instrumented with the service's OpenTelemetry providers, a PING probe and a close.
type Config struct {
config.Backplane `json:"backplane"`
Cache valkey.Config `json:"cache"` // GREETER_CACHE_ADDR, ...
}
cache := deps.NewDependency(root, valkey.New(cfg.Cache), deps.Name("cache"))
err := cache.Get().Do(ctx, cache.Get().B().Set().Key("k").Value("v").Build()).Error()
The address is a seed: a cluster is discovered from it.
NewAside is the same connection as a valkeyaside cache-aside client (client-side caching with server invalidation): AsideClient.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoAddr = errors.New("valkey: addr is required")
ErrNoAddr: the section has no address.
Functions ¶
func New ¶
New is the provider of the client: Provide connects and pings, the probe pings, Close closes.
func NewAside ¶ added in v0.6.19
func NewAside(cfg Config, opts ...AsideOption) deps.Provider[AsideClient]
NewAside is the provider of a cache-aside client on the same section as New: TLS, auth and database alike, the connection instrumented with the service's OpenTelemetry providers; Provide connects and pings, the probe pings, Close closes.
owners := deps.NewDependency(root, valkey.NewAside(cfg.Cache), deps.Name("owners"))
owner, err := owners.Get().Get(ctx, time.Minute, "owner:"+id, load)
Types ¶
type AsideClient ¶ added in v0.6.19
type AsideClient = valkeyaside.CacheAsideClient
AsideClient is valkeyaside's cache-aside client over client-side caching: Get(ctx, ttl, key, fn) reads a key, filling it once with fn across every client on a miss, and keeps it in this process until the server invalidates it. Client() is the instrumented connection underneath.
type AsideOption ¶ added in v0.6.19
type AsideOption func(*valkeyaside.ClientOption)
AsideOption tunes NewAside.
func AsideClientTTL ¶ added in v0.6.19
func AsideClientTTL(d time.Duration) AsideOption
AsideClientTTL is how long this client's liveness marker lives (refreshed every half): other clients wait no longer for a fill it abandoned. Default 10s.
func AsideLuaLock ¶ added in v0.6.19
func AsideLuaLock() AsideOption
AsideLuaLock takes fill locks with Lua scripts (valkeyaside's UseLuaLock).
type Client ¶
Client is valkey-go's client: commands are built with B() and sent with Do, DoMulti or DoCache.
type Config ¶
type Config struct {
// Addr is host:port of a node.
Addr string `json:"addr,omitempty"`
Username string `json:"username,omitempty"`
Password config.Secret `json:"password,omitempty"`
// DB is the logical database (standalone only). How many there are is
// the server's databases setting (16 by default); a number it does not
// have fails the connection.
DB int64 `json:"db" schemapb:"default=0;gte=0"`
TLS config.TLS `json:"tls"`
}
Config is the connection's section.