Help us shape the future of Go! Take the 2026 Go Developer Survey

azureredis

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 24 Imported by: 0

README

Azure Cache for Redis

Parity grade: B · SDK azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3@v3.3.0 · last audited 2026-10-22 (364908f83)

Coverage

Metric Value
PARITY entries audited 11 (10 ok, 1 partial)
Feature families 3 (3 ok)
Known gaps 13
Deferred items 0
Resource leaks clean
Known gaps
  • Microsoft.Cache/redisEnterprise (Redis Enterprise and Azure Managed Redis) is not implemented.
  • Clustering (shardCount, replicasPerPrimary), VNet injection, private endpoints, zones allocation and geo-replication data flow are not modelled; a cache is one Redis server.
  • redisConfiguration is stored and echoed; miniredis has no CONFIG, so maxmemory-policy, maxclients and notify-keyspace-events are not enforced. rdb/aof backup settings only decide whether a full reboot keeps data.
  • disableAccessKeyAuthentication and Entra ID (aad-enabled) authentication, access policies and policy assignments are not implemented.
  • Reboots do not drop open connections; firewall rules do not filter connections.
  • Import accepts one RDB file; compact ziplist/listpack/intset encodings and streams fail with a 400.
  • Create completes the server immediately; only the reported provisioningState lags.
  • Microsoft.Cache/redisEnterprise (Redis Enterprise and Azure Managed Redis) is not implemented.
  • Clustering, VNet injection, private endpoints and geo-replication data flow are not modelled.
  • redisConfiguration settings are stored but not enforced (no CONFIG in miniredis).
  • Entra ID authentication, disableAccessKeyAuthentication and access policies are not implemented.
  • Reboots do not drop connections and firewall rules do not filter them.
  • No dashboard page.

More

Documentation

Index

Constants

View Source
const (
	RebootPrimary   = "PrimaryNode"
	RebootSecondary = "SecondaryNode"
	RebootAll       = "AllNodes"
)

Reboot types accepted by Reboot.

View Source
const (
	KeyPrimary   = "Primary"
	KeySecondary = "Secondary"
)

Access key names accepted by RegenerateKey.

View Source
const (
	SKUBasic    = "Basic"
	SKUStandard = "Standard"
	SKUPremium  = "Premium"
)

SKU names.

Variables

View Source
var (
	// ErrNotFound is returned for an unknown cache.
	ErrNotFound = errors.New("azureredis: cache not found")
	// ErrInvalid is returned for a malformed request.
	ErrInvalid = errors.New("azureredis: invalid request")
	// ErrNoBlobStore is returned when import or export has no Blob Storage to talk to.
	ErrNoBlobStore = errors.New("azureredis: blob storage is not available")
	// ErrNilAppContext is returned when Init is called with a nil AppContext.
	ErrNilAppContext = errors.New("azureredis: nil app context")
)

Functions

This section is empty.

Types

type BlobStore

type BlobStore interface {
	ReadBlob(container, blob string) ([]byte, error)
	WriteBlob(container, blob string, data []byte) error
}

BlobStore reads and writes blobs in the Blob Storage emulator, for ImportData and ExportData.

type ConfigProvider

type ConfigProvider interface {
	GetAzureRedisSettings() Settings
}

ConfigProvider extracts the Azure Cache for Redis settings from the AppContext config.

type Endpoint

type Endpoint struct {
	Host    string
	Port    int
	SSLPort int
}

Endpoint is where a cache's servers listen. Port is 0 while the non-TLS port is disabled.

type Handler

type Handler struct {
	Backend *InMemoryBackend
}

Handler owns the cache servers. Azure Cache for Redis has no HTTP data plane: ARM manages caches and clients speak Redis to each cache's own ports, so the handler never matches a request.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler wraps backend.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(*echo.Context) string

ExtractOperation is unused: requests never reach the shared router.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(*echo.Context) string

ExtractResource is unused: requests never reach the shared router.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the operations ARM's Microsoft.Cache provider drives.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns a 404 handler.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset stops every cache.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches.

func (*Handler) Shutdown

func (h *Handler) Shutdown(context.Context)

Shutdown stops every cache.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend runs one embedded Redis server per cache, with a TLS port always on and a plaintext port only while the cache enables it.

func NewInMemoryBackend

func NewInMemoryBackend(cfg Settings) *InMemoryBackend

NewInMemoryBackend creates an empty backend on ephemeral loopback ports.

func (*InMemoryBackend) Close

func (b *InMemoryBackend) Close()

Close stops every cache.

func (*InMemoryBackend) Delete

func (b *InMemoryBackend) Delete(key string) error

Delete stops the cache's servers and discards its data.

func (*InMemoryBackend) Endpoint

func (b *InMemoryBackend) Endpoint(key string) (Endpoint, bool)

Endpoint reports where the cache listens.

func (*InMemoryBackend) Ensure

func (b *InMemoryBackend) Ensure(key string, spec Spec) (Endpoint, error)

Ensure creates the cache, or applies spec to an existing one, and returns where it listens.

func (*InMemoryBackend) Export

func (b *InMemoryBackend) Export(key, format, prefix, containerURL string) error

Export writes the cache's data to <prefix>.rdb in the container named by containerURL.

func (*InMemoryBackend) Import

func (b *InMemoryBackend) Import(key, format string, files []string) error

Import replaces the cache's data with the RDB file at the blob URL.

func (*InMemoryBackend) Keys

func (b *InMemoryBackend) Keys(key string) (Keys, error)

Keys returns the cache's access keys.

func (*InMemoryBackend) Reboot

func (b *InMemoryBackend) Reboot(key, rebootType string) error

Reboot restarts the selected nodes. Data is flushed when no surviving node or persisted copy holds it.

func (*InMemoryBackend) RegenerateKey

func (b *InMemoryBackend) RegenerateKey(key, keyType string) (Keys, error)

RegenerateKey replaces one access key; the old value stops authenticating.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset stops every cache.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads a snapshot, starting every cache again on fresh ports.

func (*InMemoryBackend) SetBlobStore

func (b *InMemoryBackend) SetBlobStore(s BlobStore)

SetBlobStore connects ImportData and ExportData to Blob Storage.

func (*InMemoryBackend) SetPortPool

func (b *InMemoryBackend) SetPortPool(alloc *portalloc.Allocator)

SetPortPool makes caches take their Redis ports from alloc.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises every cache with its keys and keyspace; servers and ports are rebuilt on restore.

type Keys

type Keys struct {
	Primary   string
	Secondary string
}

Keys are a cache's two access keys; either authenticates.

type Provider

type Provider struct{}

Provider implements service.Provider for Azure Cache for Redis.

func (*Provider) Init

Init builds the backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Settings

type Settings struct {
	TLSCertFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 215-byte string literal not displayed */
	TLSKeyFile string `json:"tlsKeyFile"  env:"AZURE_REDIS_TLS_KEY"  name:"tls-key"  help:"Path to the PEM key matching --azure-redis-tls-cert."` //nolint:lll // config struct tags are intentionally verbose
}

Settings is the Kong-embedded configuration of the Azure Cache for Redis emulator.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider exists.

type Spec

type Spec struct {
	// SKU is Basic, Standard or Premium.
	SKU string `json:"sku"`
	// MinTLS is "1.0", "1.1" or "1.2".
	MinTLS string `json:"minTls"`
	// EnableNonSSLPort serves plaintext Redis on a second port.
	EnableNonSSLPort bool `json:"enableNonSslPort"`
	// Persistence is true when RDB or AOF backup is enabled, so a full reboot keeps the data.
	Persistence bool `json:"persistence"`
	// AuthNotRequired (redisConfiguration authnotrequired) lets clients connect without a key.
	AuthNotRequired bool `json:"authNotRequired,omitempty"`
}

Spec is the part of a cache's ARM configuration the Redis servers act on.

Jump to

Keyboard shortcuts

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