Skip to Content

Cache

This page covers building custom cache providers. If you only need to bind a cache into a plugin, use Providers > Cache.

Cache providers expose a small portable interface for cache-oriented backends such as Redis, Valkey, Memcached-style services, or in-memory implementations. The contract is intentionally narrower than IndexedDB: opaque byte values, relative TTLs, batch helpers, delete, and touch.

Manifest

A cache provider manifest declares kind: cache:

kind: cache source: github.com/valon-technologies/gestalt-providers/cache/valkey version: 0.0.1 displayName: Valkey Cache description: Cache provider backed by Valkey or Redis. spec: configSchemaPath: ./cache_config.json

Provider interface

The Cache service includes:

MethodPurpose
GetRead a value by key
GetManyRead multiple keys in one request
SetWrite a value with optional TTL
SetManyWrite multiple values with one TTL policy
DeleteRemove one key
DeleteManyRemove multiple keys
TouchRefresh TTL for an existing key
package valkeycache import ( "context" "time" gestalt "github.com/valon-technologies/gestalt/sdk/go" ) type Provider struct{} func New() *Provider { return &Provider{} } func (p *Provider) Configure(_ context.Context, _ string, config map[string]any) error { return nil } func (p *Provider) Get(ctx context.Context, key string) ([]byte, bool, error) { return nil, false, nil } func (p *Provider) Set(ctx context.Context, key string, value []byte, opts gestalt.CacheSetOptions) error { _ = opts.TTL return nil } func (p *Provider) Delete(ctx context.Context, key string) (bool, error) { return false, nil } func (p *Provider) Touch(ctx context.Context, key string, ttl time.Duration) (bool, error) { return false, nil }

Python, Rust, and TypeScript cache providers inherit default implementations for GetMany, SetMany, and DeleteMany. Override the batch helpers only when the backing cache can do better than repeated single-key calls.

Plugin SDK

Plugins consume bound caches through the language SDK. The host exposes a Unix socket for each requested cache binding.

When a plugin binds exactly one cache, the host sets both:

  • GESTALT_CACHE_SOCKET
  • GESTALT_CACHE_SOCKET_<NAME>

When a plugin binds multiple caches, only the named env vars are set.

cache, err := gestalt.Cache("") if err != nil { panic(err) } defer cache.Close() if err := cache.Set(ctx, "session", []byte("alpha"), gestalt.CacheSetOptions{}); err != nil { panic(err) }

Release flow

Managed cache providers follow the same gestaltd init / lockfile / release flow as other source-backed provider kinds. Point a manifest at a published source ref, run gestaltd init, and package releases with gestaltd provider release.