efritz/gache

View on GitHub
redis_options.go

Summary

Maintainability
A
0 mins
Test Coverage
package gache

import "time"

// RedisConfig is a function use dot configure instances of a
// Cache which uses a Redis backend.
type RedisConfig func(*redisCache)

// WithRedisPrefix sets the prefix used in the Redis backend.
func WithRedisPrefix(prefix string) RedisConfig {
    return func(rc *redisCache) { rc.prefix = prefix }
}

// WithRedisTTL sets the TTL for keys stored in the Redis backend.
func WithRedisTTL(ttl time.Duration) RedisConfig {
    return func(rc *redisCache) { rc.ttl = int(ttl / time.Second) }
}