Documentation
¶
Overview ¶
Package cachevalkey adapts valkey-go clients to the cache backend contract. Clients remain caller-owned; configure their TLS, retries and deadlines. Writes use relative server expiry to StaleAt, with a 1 ms minimum; clock skew, transport latency and provider retry semantics remain observable. Constructors do not ping/open/close clients. Standalone is the documented supported topology.
Index ¶
- type Backend
- func (b *Backend) Delete(ctx context.Context, key string) (bool, error)
- func (b *Backend) Get(ctx context.Context, key string) (cache.Record, bool, error)
- func (b *Backend) Set(ctx context.Context, key string, record cache.Record, ...) (bool, error)
- func (b *Backend) SetIfOwned(ctx context.Context, key string, record cache.Record, ...) error
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements cache.Backend with valkey-go.
func (*Backend) Get ¶
Get reads and validates one bounded wire record. The Lua preflight rejects oversized string values before GET; malformed/wrong-type data remains an error. Raw backend reads can outlive local StaleAt due to server/clock timing.
func (*Backend) Set ¶
func (b *Backend) Set( ctx context.Context, key string, record cache.Record, condition cache.Condition, ) (bool, error)
Set atomically writes a record with its stale deadline as relative expiry. Non-positive remaining TTL is rejected; positive sub-millisecond TTL uses 1 ms. Conditions test server key existence, not a record-version fence.
func (*Backend) SetIfOwned ¶
func (b *Backend) SetIfOwned( ctx context.Context, key string, record cache.Record, guard cache.OwnershipGuard, ) error
SetIfOwned atomically compares an active Valkey lease hash and publishes the record. A missing, expired, or superseded lease returns ErrOwnershipLost. The guard must describe a compatible hash on the same supported standalone deployment. Tokens are compared for equality, not numeric ordering. This neither acquires/renews a lease nor fences durable non-cache side effects.
type Config ¶
type Config struct {
// Client is caller-owned; configure concurrency, TLS, retries and timeouts externally.
Client valkeyclient.CommandClient
// Clock is retained for relative TTL calculation; clock skew affects server expiry.
Clock cache.Clock
// MaxRecordSize is the positive wire-byte ceiling, including the 21-byte envelope header.
MaxRecordSize int
}
Config supplies the native client, clock, and maximum wire record size.