Documentation
¶
Overview ¶
Package redis caches bytes using native Redis expiration. It borrows an existing client from pkg/redis and supports standalone, Sentinel and Cluster clients.
Index ¶
- type Config
- type Store
- func (s *Store) Clear(ctx context.Context) error
- func (s *Store) Delete(ctx context.Context, key string) error
- func (s *Store) Exists(ctx context.Context, key string) (bool, error)
- func (s *Store) Get(ctx context.Context, key string) ([]byte, bool, error)
- func (s *Store) GetMulti(ctx context.Context, keys []string) (map[string][]byte, error)
- func (s *Store) Remember(ctx context.Context, key string, ttl time.Duration, ...) (any, error)
- func (s *Store) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- func (s *Store) SetMulti(ctx context.Context, items map[string][]byte, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is safe for concurrent use. The caller owns the client and closes it after all users stop. Configure context-aware I/O using pkg/redis.Open or OpenURL.
func (*Store) Clear ¶
Clear scans only this namespace and unlinks keys in batches. It never flushes the database. All cluster primaries are scanned. Concurrent writes/topology changes may survive; quiesce writers for a complete clear. Errors can leave partial progress. The operation has one deadline for the entire traversal.
func (*Store) Remember ¶
func (s *Store) Remember(ctx context.Context, key string, ttl time.Duration, load func(context.Context) (any, error)) (any, error)
Remember returns a cached JSON value or loads it on a miss. See cache.Remember for validation, error, expiry and concurrent-loading semantics.