Documentation ¶
Index ¶
Constants ¶
View Source
const ( ProviderEtcd = "etcd" ProviderRedis = "redis" ProviderMemory = "memory" )
View Source
const ( Redis = "redis" RedisSentinel = "redis-sentinel" RedisCluster = "redis-cluster" )
View Source
const NoExpiration time.Duration = 0
Variables ¶
View Source
var ErrNotExists = fmt.Errorf("key not exists")
Functions ¶
func IsNotExists ¶
Types ¶
type Interface ¶
type Interface interface { Set(key, value string, expire time.Duration) error Update(key, newValue string) error Get(key string) (value string, err error) Exist(key string) (bool, error) Remove(key string) error Expire(key string, expire time.Duration) error }
func NewEtcd ¶
func NewEtcd(reader iam.TokenReader, writer iam.TokenWriter) (Interface, error)
func NewRedis ¶
func NewRedis(opt *RedisOptions) (Interface, error)
type Options ¶
type Options struct { CacheProvider string `json:"cacheProvider" yaml:"cacheProvider"` RedisOptions *RedisOptions `json:"redis,omitempty" yaml:"redis,omitempty" mapstructure:"redis"` }
func NewEtcdOptions ¶
func NewEtcdOptions() *Options
type RedisOptions ¶
type RedisOptions struct { // redis schema. one of redis redis-sentinel cluster Schema string `json:"schema"` Addrs []string `json:"addrs" yaml:"addrs"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` DB int `json:"db" yaml:"db"` MasterName string `json:"masterName" yaml:"masterName"` SentinelUsername string `json:"sentinelUsername" yaml:"sentinelUsername"` SentinelPassword string `json:"sentinelPassword" yaml:"sentinelPassword"` Prefix string `json:"prefix" yaml:"prefix"` }
func NewRedisOptions ¶
func NewRedisOptions() *RedisOptions
func (*RedisOptions) AddFlags ¶
func (s *RedisOptions) AddFlags(fs *pflag.FlagSet)
AddFlags specified FlagSet
func (*RedisOptions) Validate ¶
func (s *RedisOptions) Validate() []error
Click to show internal directories.
Click to hide internal directories.