Documentation ¶
Overview ¶
Package rediskv contains implementation of remotekv.Interface for Redis.
Index ¶
Constants ¶
const ( // MinTTL is the minimum TTL that can be set when setting any TTL. MinTTL = 1 * time.Millisecond )
Redis-related constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmptyMetrics ¶
type EmptyMetrics struct{}
EmptyMetrics is the implementation of the Metrics interface that does nothing.
func (EmptyMetrics) UpdateMetrics ¶
func (EmptyMetrics) UpdateMetrics(_ context.Context, _ uint, _ bool)
UpdateMetrics implements the Metrics interface for EmptyMetrics.
type Metrics ¶
type Metrics interface { // UpdateMetrics updates the total number of active connections and // increments the total number of errors if necessary. UpdateMetrics(ctx context.Context, val uint, isSuccess bool) }
Metrics is an interface that is used for the collection of the Redis KV statistics.
type RedisKV ¶
type RedisKV struct {
// contains filtered or unexported fields
}
RedisKV is a Redis implementation of the remotekv.Interface interface.
Note that Redis, by convention, uses colon ":" character to delimit key namespaces. This process should be handled by remotekv.KeyNamespace.
TODO(a.garipov): Find ways of testing.
func NewRedisKV ¶
func NewRedisKV(c *RedisKVConfig) (kv *RedisKV)
NewRedisKV returns a new *RedisKV. c must not be nil.
func (*RedisKV) Get ¶
Get implements the remotekv.Interface interface for *RedisKV.
type RedisKVConfig ¶
type RedisKVConfig struct { // Metrics is used for the collection of the Redis KV statistics. Metrics Metrics // Addr is the address of the Redis server. Addr *netutil.HostPort // MaxActive is the maximum number of connections allocated by the Redis // connection-pool at a given time. When zero, there is no limit on the // number of connections in the pool. MaxActive int // MaxIdle is the maximum number of idle connections in the pool. When // zero, there is no limit. MaxIdle int // IdleTimeout is the time after remaining, idle connection will be closed. IdleTimeout time.Duration // TTL defines, after how much time the keys should expire. TTL must be // greater than or equal to [MinTTL], since that's the minimum expiration // allowed by Redis. TTL time.Duration }
RedisKVConfig is the configuration for the Redis-based remotekv.Interface implementation. All fields must not be empty.