Documentation
¶
Index ¶
- func New(opts ...Option) func(gas.ConfigProvider, gas.Logger) *Service
- type Config
- type Option
- type Service
- func (s *Service) CheckHealth(_ context.Context) error
- func (s *Service) CheckReady(ctx context.Context) error
- func (s *Service) Client() valkey.Client
- func (s *Service) Close() error
- func (s *Service) Delete(ctx context.Context, key string) error
- func (s *Service) Exists(ctx context.Context, key string) (bool, error)
- func (s *Service) Get(ctx context.Context, key string) ([]byte, error)
- func (s *Service) Init() error
- func (s *Service) Name() string
- func (s *Service) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
env.WithGasEnv
Cache Settings
}
Config holds Valkey cache settings.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a Valkey-backed cache implementing gas.Service and gas.CacheProvider.
func (*Service) CheckHealth ¶
CheckHealth reports liveness. The valkey-go client reconnects internally, so a transient network failure is not a liveness failure; only a closed service is.
func (*Service) CheckReady ¶
CheckReady reports readiness by pinging the Valkey server with the caller's context.
func (*Service) Get ¶
Get returns the value for the given key, or cache.ErrKeyNotFound if the key does not exist.
type Settings ¶
type Settings struct {
// Addr is the Valkey server address in host:port format.
Addr string
// Password is the authentication password. Empty means no auth.
//nolint:gosec // intentional
Password string
// DB is the database number to use (0-15).
DB int
// DialTimeout is the timeout for establishing new connections.
DialTimeout time.Duration
// WriteTimeout is applied to net.Conn.SetDeadline and controls
// the maximum duration for write operations and periodic PINGs.
WriteTimeout time.Duration
// ConnRetries is the number of times to retry connecting on failure.
// 0 means no retries (fail immediately).
ConnRetries int
// ConnRetryInterval is the base interval between connection retry
// attempts. The interval doubles after each failed attempt.
ConnRetryInterval time.Duration
}
Settings represents the configuration for the Valkey cache.
Click to show internal directories.
Click to hide internal directories.