Documentation ¶
Overview ¶
Package storage provides a type for storing Go objects in Redis.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is the error returned when the given key is not found.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Comma-separated list of sentinel servers. // // Example: 10.10.10.10:6379,10.10.10.1:6379,10.10.10.2:6379. SentinelAddrs string `envconfig:"SENTINEL_ADDRS"` SentinelMasterName string `envconfig:"SENTINEL_MASTER_NAME"` RedisAddr string `envconfig:"REDIS_ADDR" default:"127.0.0.1:6379"` Password string `envconfig:"REDIS_PASSWORD"` PoolSize int `envconfig:"REDIS_POOL_SIZE"` PoolTimeout int `envconfig:"REDIS_POOL_TIMEOUT_SECONDS"` IdleTimeout int `envconfig:"REDIS_IDLE_TIMEOUT_SECONDS"` IdleCheckFrequency int `envconfig:"REDIS_IDLE_CHECK_FREQUENCY_SECONDS"` }
Config contains configuration for the Redis, in the standard proposed by Gizmo.
func (*Config) RedisClient ¶
RedisClient creates a new instance of the client using the underlying configuration.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is the basic type that provides methods for saving, listing and deleting types on Redis.
func NewStorage ¶
NewStorage returns a new instance of storage with the given configuration.
func (*Storage) Delete ¶
Delete deletes the given key from redis, returning ErrNotFound when it doesn't exist.
func (*Storage) FieldMap ¶
FieldMap extract the map of fields from the given type (which can be a struct, a map[string]string or pointer to those).
func (*Storage) Load ¶
Load loads the given key in the given output. The output must be a pointer to a struct or a map[string]string.
func (*Storage) RedisClient ¶
RedisClient returns the underlying Redis client.