Documentation
¶
Overview ¶
Package redis provides a Redis- or Valkey-backed gateway.CertStore, so that every process in a deployment shares one persistent certificate store: a node that cold-starts fetches already-issued certificates back from the server instead of depending on the issuer being reachable/willing to re-issue. It is a separate package specifically so that importing the root gateway package never pulls in github.com/redis/go-redis/v9 for applications that use the default gateway.MemoryCertStore or gateway.FileCertStore.
go-redis speaks the same RESP protocol to Redis and to Valkey (a BSD-licensed fork of Redis 7.2.4), so the constructor takes a goredis.UniversalClient pointed at either one and the code below carries no Redis-versus-Valkey branch. Only core string commands are used, which both servers implement identically.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Store)
Option configures a Store created with New.
func WithKeyPrefix ¶
WithKeyPrefix namespaces every key this Store reads or writes, so multiple gateway deployments (or unrelated applications) can share one Redis instance/database without colliding. Defaults to no prefix.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a gateway.CertStore backed by a Redis or Valkey client: each certificate is stored under its own key with no TTL, so a certificate survives until it is overwritten by Put or removed by Delete. Server-side persistence (Redis RDB/AOF, or the Valkey equivalent) is what makes the store survive a full deployment restart, which is the reason to plug it in over MemoryCertStore. Only core string commands (GET/SET/DEL) are used, all present and identical on Redis 7.2 and Valkey 8, so one client pointed at either server works with no code change.
func New ¶
func New(client goredis.UniversalClient, opts ...Option) *Store
New creates a Store backed by client. client may be a *redis.Client, *redis.ClusterClient, *redis.Ring, or any other goredis.UniversalClient implementation, pointed at either a Redis or a Valkey server.
Example ¶
ExampleNew persists issued certificates so a cold-starting node fetches them back from the server instead of depending on the issuer to re-issue. Get reports gateway.ErrCertificateNotFound for a domain that was never stored.
package main
import (
"context"
"errors"
"log"
goredis "github.com/redis/go-redis/v9"
gateway "github.com/StringKe/goakt-gateway"
storeredis "github.com/StringKe/goakt-gateway/store/redis"
)
func main() {
client := goredis.NewClient(&goredis.Options{Addr: "localhost:6379"})
defer func() { _ = client.Close() }()
store := storeredis.New(client, storeredis.WithKeyPrefix("myapp:"))
ctx := context.Background()
_, err := store.Get(ctx, "example.com")
if errors.Is(err, gateway.ErrCertificateNotFound) {
log.Println("no certificate yet; issue and Put one")
}
}
Output:
func (*Store) Delete ¶
Delete implements gateway.CertStore. It is idempotent: deleting a domain with no stored certificate is not an error.
func (*Store) Get ¶
Get implements gateway.CertStore. It returns gateway.ErrCertificateNotFound when no certificate is stored for domain.