valkey

package module
v1.21.45 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package valkey backs clicky's cache.Store (and cache.Browser) with a valkey/redis server. It lives in a separate Go module so the valkey-go dependency stays out of the root clicky module: callers that only need the in-process stores (cache.NewMemory) never pull it in.

NewStore returns a cache.Store adapter over a valkey.Client; the domain stores compose over it, e.g. prompt.NewStore(valkey.NewStore(client), cfg) and metrics.NewStore(valkey.NewStore(client), cfg). One adapter (and one client) can back the prompt store, the metrics store, and the cache browser at once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBrowser

func NewBrowser(client valkey.Client, cfg BrowserConfig) cache.Browser

NewBrowser returns a cache.Browser over client. The client is owned by the caller (NewBrowser does not close it), so an app can share its existing connection.

func NewStore added in v1.21.34

func NewStore(client valkey.Client) cache.Store

NewStore returns a cache.Store backed by client. The client is owned by the caller (NewStore does not close it), so an app can share its existing connection rather than opening a second one.

Types

type BrowserConfig

type BrowserConfig struct {
	// KeyPrefix is the physical namespace shared with the rest of the app
	// (the same prefix the cache writes with). It is stripped from every key
	// the browser returns and re-applied on lookups, so the API speaks
	// logical keys only.
	KeyPrefix string
	// Separator splits keys into tree segments. Default ":".
	Separator string
	// MaxScan caps the number of keys a single tree/search/stats request
	// scans. Default 100000.
	MaxScan int
	// MaxChildren caps the number of nodes returned per tree level. Default
	// 1000.
	MaxChildren int
	// MaxValueBytes caps the string value returned by Key. Default 256KiB.
	MaxValueBytes int
	// MaxItems caps the collection items returned by Key. Default 1000.
	MaxItems int
	// OpTimeout bounds a whole browser request. Scans over large keyspaces
	// take longer than single-key ops, so this is deliberately more generous
	// than the timeseries opTimeout. Default 10s.
	OpTimeout time.Duration
}

BrowserConfig tunes the valkey-backed cache.Browser.

Jump to

Keyboard shortcuts

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