Documentation
¶
Index ¶
- func NewMetricsHook() redis.Hook
- type Service
- func (s *Service) Delete(ctx context.Context, key string) error
- func (s *Service) DeleteByPrefix(ctx context.Context, prefix string) error
- func (s *Service) DeleteSession(ctx context.Context, sessionID string) error
- func (s *Service) Get(ctx context.Context, key string) (string, error)
- func (s *Service) GetClient() *redis.Client
- func (s *Service) GetObject(ctx context.Context, key string, value interface{}) error
- func (s *Service) GetSession(ctx context.Context, sessionID string) (*types.CachedSession, error)
- func (s *Service) Ping(ctx context.Context) error
- func (s *Service) Set(ctx context.Context, key string, value string, expiration time.Duration) error
- func (s *Service) SetNX(ctx context.Context, key string, value string, expiration time.Duration) (bool, error)
- func (s *Service) SetObject(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- func (s *Service) SetSession(ctx context.Context, sessionID string, session types.CachedSession, ...) error
- func (s *Service) Start() error
- func (s *Service) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMetricsHook ¶
NewMetricsHook returns a redis.Hook that records command latency and errors on the prometheus default registry. Exported so other Redis clients in the binary (e.g. the DEK cache client constructed in internal/app) can attach the same hook for consistent dashboard data.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles Redis cache operations
func (*Service) DeleteByPrefix ¶
DeleteByPrefix deletes all keys matching the given prefix using SCAN + DEL. Uses UNLINK for non-blocking deletion when available (Redis 4.0+).
func (*Service) DeleteSession ¶
DeleteSession deletes a session from the cache
func (*Service) GetClient ¶
GetClient returns the underlying Redis client so other services can reuse the same connection pool instead of opening a duplicate client to the same Redis instance (e.g. the rate limiter). The client remains owned by the cache service and is closed when the cache service stops; callers must not close it themselves.
func (*Service) GetObject ¶
GetObject gets an object from the cache and unmarshals it into the provided value
func (*Service) GetSession ¶
GetSession retrieves a typed session from the cache. Returns nil, nil when the key does not exist.
func (*Service) Set ¶
func (s *Service) Set(ctx context.Context, key string, value string, expiration time.Duration) error
Set sets a value in the cache
func (*Service) SetNX ¶
func (s *Service) SetNX(ctx context.Context, key string, value string, expiration time.Duration) (bool, error)
SetNX atomically sets a key only if it does not already exist. Returns true if the key was set, false if it already existed.
func (*Service) SetObject ¶
func (s *Service) SetObject(ctx context.Context, key string, value interface{}, expiration time.Duration) error
SetObject sets an object in the cache