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.jsonProvider interface
The Cache service includes:
| Method | Purpose |
|---|---|
Get | Read a value by key |
GetMany | Read multiple keys in one request |
Set | Write a value with optional TTL |
SetMany | Write multiple values with one TTL policy |
Delete | Remove one key |
DeleteMany | Remove multiple keys |
Touch | Refresh TTL for an existing key |
Go
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_SOCKETGESTALT_CACHE_SOCKET_<NAME>
When a plugin binds multiple caches, only the named env vars are set.
Go
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.