Documentation
¶
Index ¶
- func NewRedisCache(addr string, password string, db int, logger *logrus.Logger) (ports.Cache, error)
- type RedisCache
- func (r *RedisCache) Close() error
- func (r *RedisCache) Delete(ctx context.Context, key string) error
- func (r *RedisCache) Get(ctx context.Context, key string) (string, error)
- func (r *RedisCache) InvalidateByPrefix(ctx context.Context, prefix string) error
- func (r *RedisCache) Set(ctx context.Context, key string, value []byte, expiration time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func (*RedisCache) Close ¶
func (r *RedisCache) Close() error
func (*RedisCache) InvalidateByPrefix ¶ added in v1.2.0
func (r *RedisCache) InvalidateByPrefix(ctx context.Context, prefix string) error
InvalidateByPrefix deletes all keys that start with the given prefix. It uses the SCAN command to iterate over keys matching the pattern and then deletes them. Note: While SCAN is generally safe for production, performing many DEL commands in a tight loop could still put load on Redis. For extremely large datasets, consider optimizing further (e.g., pipelining DEL commands, or relying on TTL for less critical keys).
Click to show internal directories.
Click to hide internal directories.