Documentation ¶
Overview ¶
Package redis implements a service to store data in redis. This can be used in production.
Index ¶
- func IsExecutionFailed(err error) bool
- func IsInvalidConfig(err error) bool
- func IsInvalidExecution(err error) bool
- func IsNotFound(err error) bool
- func NewDial(config DialConfig) func() (redis.Conn, error)
- func NewMockDial(config MockDialConfig) func() (redis.Conn, error)
- func NewPool(config PoolConfig) *redis.Pool
- func NewPoolWithAddress(address string) *redis.Pool
- type Backoff
- type Config
- type DialConfig
- type MockDialConfig
- type PoolConfig
- type Service
- func (s *Service) Boot()
- func (s *Service) Exists(key string) (bool, error)
- func (s *Service) ExistsInScoredSet(key, element string) (bool, error)
- func (s *Service) Get(key string) (string, error)
- func (s *Service) GetAllFromList(key string) ([]string, error)
- func (s *Service) GetAllFromSet(key string) ([]string, error)
- func (s *Service) GetElementsByScore(key string, score float64, maxElements int) ([]string, error)
- func (s *Service) GetHighestScoredElements(key string, maxElements int) ([]string, error)
- func (s *Service) GetRandom() (string, error)
- func (s *Service) GetRandomFromScoredSet(key string) (string, error)
- func (s *Service) GetRandomFromSet(key string) (string, error)
- func (s *Service) GetScoreOfElement(key, element string) (float64, error)
- func (s *Service) GetStringMap(key string) (map[string]string, error)
- func (s *Service) Increment(key string, n float64) (float64, error)
- func (s *Service) IncrementScoredElement(key, element string, n float64) (float64, error)
- func (s *Service) LengthOfList(key string) (int, error)
- func (s *Service) LengthOfScoredSet(key string) (int, error)
- func (s *Service) PopFromList(key string) (string, error)
- func (s *Service) PushToList(key string, element string) error
- func (s *Service) PushToSet(key string, element string) error
- func (s *Service) Remove(key string) error
- func (s *Service) RemoveFromList(key string, element string) error
- func (s *Service) RemoveFromSet(key string, element string) error
- func (s *Service) RemoveScoredElement(key string, element string) error
- func (s *Service) Set(key, value string) error
- func (s *Service) SetElementByScore(key, element string, score float64) error
- func (s *Service) SetStringMap(key string, stringMap map[string]string) error
- func (s *Service) Shutdown()
- func (s *Service) TrimEndOfList(key string, maxElements int) error
- func (s *Service) WalkKeys(glob string, closer <-chan struct{}, cb func(key string) error) error
- func (s *Service) WalkScoredSet(key string, closer <-chan struct{}, ...) error
- func (s *Service) WalkSet(key string, closer <-chan struct{}, cb func(element string) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsExecutionFailed ¶
IsExecutionFailed asserts executionFailedError.
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
func IsInvalidExecution ¶
IsInvalidExecution asserts invalidExecutionError.
func IsNotFound ¶
IsNotFound checks whether a redis response was empty. Therefore it checks for redigo.ErrNil and notFoundError.
ErrNil indicates that a reply value is nil.
func NewDial ¶
func NewDial(config DialConfig) func() (redis.Conn, error)
NewDial creates a new configured redis dialer.
func NewMockDial ¶
func NewMockDial(config MockDialConfig) func() (redis.Conn, error)
func NewPool ¶
func NewPool(config PoolConfig) *redis.Pool
NewPool creates a new configured redis pool.
func NewPoolWithAddress ¶
Types ¶
type Backoff ¶
type Backoff interface { // NextBackOff provides the duration expected to wait before retrying an // action. time.Duration = -1 indicates that no more retry should be // attempted. NextBackOff() time.Duration // Reset sets the backoff back to its initial state. Reset() }
Backoff represents the object managing backoff algorithms to retry actions.
type Config ¶
type Config struct { // Dependencies. BackoffFactory func() Backoff InstrumentorCollection *instrumentor.Collection LoggerService logger.Service RandomService random.Service // Settings. Address string Pool *redis.Pool Prefix string }
Config represents the configuration used to create a new storage service.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig provides a default configuration to create a new storage service by best effort.
type DialConfig ¶
type DialConfig struct { // Address represents the address used to connect to a redis server. Address string }
DialConfig represents the configuration used to create a new redis dialer.
func DefaultDialConfig ¶
func DefaultDialConfig() DialConfig
DefaultDialConfig provides a default configuration to create a new redis dialer by best effort.
type MockDialConfig ¶
func DefaultMockDialConfig ¶
func DefaultMockDialConfig() MockDialConfig
type PoolConfig ¶
type PoolConfig struct { // MaxIdle is the allowed maximum number of idle connections in the pool. MaxIdle int // MaxActive is the allowed maximum number of connections allocated by the // pool at a given time. When zero, there is no limit on the number of // connections in the pool. MaxActive int // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not closed. Applications should set // the timeout to a value less than the server's timeout. IdleTimeout time.Duration // Dial is an application supplied function for creating and configuring a // redis connection on demand. Dial func() (redis.Conn, error) }
PoolConfig represents the configuration used to create a new redis pool.
func DefaultPoolConfig ¶
func DefaultPoolConfig() PoolConfig
DefaultPoolConfig provides a default configuration to create a new redis pool by best effort.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}