Documentation ¶
Index ¶
- Variables
- type Config
- type ElasticacheClient
- func (c *ElasticacheClient) Checker(ctx context.Context, state *health.CheckState) error
- func (c *ElasticacheClient) DeleteAll() error
- func (c *ElasticacheClient) Expire(key string, expiration time.Duration) error
- func (c *ElasticacheClient) GetByEmail(email string) (*session.Session, error)
- func (c *ElasticacheClient) GetByID(id string) (*session.Session, error)
- func (c *ElasticacheClient) Ping() error
- func (c *ElasticacheClient) SetSession(s *session.Session) error
- type RedisClienter
- type RedisClienterMock
- func (mock *RedisClienterMock) Expire(key string, expiration time.Duration) *redis.BoolCmd
- func (mock *RedisClienterMock) ExpireCalls() []struct{ ... }
- func (mock *RedisClienterMock) FlushAll() *redis.StatusCmd
- func (mock *RedisClienterMock) FlushAllCalls() []struct{}
- func (mock *RedisClienterMock) Get(key string) *redis.StringCmd
- func (mock *RedisClienterMock) GetCalls() []struct{ ... }
- func (mock *RedisClienterMock) Ping() *redis.StatusCmd
- func (mock *RedisClienterMock) PingCalls() []struct{}
- func (mock *RedisClienterMock) Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd
- func (mock *RedisClienterMock) SetCalls() []struct{ ... }
- type SessionCache
Constants ¶
This section is empty.
Variables ¶
var ( HealthyMessage = "elasticache is OK" ErrEmptySessionID = errors.New("session id required but was empty") ErrEmptySessionEmail = errors.New("session email required but was empty") ErrEmptySession = errors.New("session is empty") ErrEmptyAddress = errors.New("address is empty") ErrEmptyPassword = errors.New("password is empty") ErrInvalidTTL = errors.New("ttl should not be zero") ErrSessionNotFound = errors.New("session not found") )
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v1.1.0
type Config struct { Addr string Password string `json:"-"` Database int TTL time.Duration TLS *tls.Config }
Config - config options for the elasticache client
type ElasticacheClient ¶ added in v1.1.0
type ElasticacheClient struct {
// contains filtered or unexported fields
}
func New ¶ added in v1.1.0
func New(c Config) (*ElasticacheClient, error)
New - create new session cache client instance
func (*ElasticacheClient) Checker ¶ added in v1.1.0
func (c *ElasticacheClient) Checker(ctx context.Context, state *health.CheckState) error
func (*ElasticacheClient) DeleteAll ¶ added in v1.1.0
func (c *ElasticacheClient) DeleteAll() error
DeleteAll - removes all items from elasticache
func (*ElasticacheClient) Expire ¶ added in v1.1.0
func (c *ElasticacheClient) Expire(key string, expiration time.Duration) error
Expire - sets the expiration of key
func (*ElasticacheClient) GetByEmail ¶ added in v1.1.0
func (c *ElasticacheClient) GetByEmail(email string) (*session.Session, error)
GetByEmail - gets a session from elasticache by the email address. Returns cache.ErrSessionNotFound if a session with the specified email does not exist.
func (*ElasticacheClient) GetByID ¶ added in v1.1.0
func (c *ElasticacheClient) GetByID(id string) (*session.Session, error)
GetByID - gets a session from elasticache by the Session ID. Returns cache.ErrSessionNotFound if the session with the specified ID does not exist.
func (*ElasticacheClient) Ping ¶ added in v1.1.0
func (c *ElasticacheClient) Ping() error
Ping - checks the connection to elasticache
func (*ElasticacheClient) SetSession ¶ added in v1.1.0
func (c *ElasticacheClient) SetSession(s *session.Session) error
SetSession - add session to elasticache
type RedisClienter ¶ added in v1.1.0
type RedisClienter interface { Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd Get(key string) *redis.StringCmd Expire(key string, expiration time.Duration) *redis.BoolCmd FlushAll() *redis.StatusCmd Ping() *redis.StatusCmd }
RedisClienter - interface for redis
type RedisClienterMock ¶ added in v1.1.0
type RedisClienterMock struct { // ExpireFunc mocks the Expire method. ExpireFunc func(key string, expiration time.Duration) *redis.BoolCmd // FlushAllFunc mocks the FlushAll method. FlushAllFunc func() *redis.StatusCmd // GetFunc mocks the Get method. GetFunc func(key string) *redis.StringCmd // PingFunc mocks the Ping method. PingFunc func() *redis.StatusCmd // SetFunc mocks the Set method. SetFunc func(key string, value interface{}, expiration time.Duration) *redis.StatusCmd // contains filtered or unexported fields }
RedisClienterMock is a mock implementation of RedisClienter.
func TestSomethingThatUsesRedisClienter(t *testing.T) { // make and configure a mocked RedisClienter mockedRedisClienter := &RedisClienterMock{ ExpireFunc: func(key string, expiration time.Duration) *redis.BoolCmd { panic("mock out the Expire method") }, FlushAllFunc: func() *redis.StatusCmd { panic("mock out the FlushAll method") }, GetFunc: func(key string) *redis.StringCmd { panic("mock out the Get method") }, PingFunc: func() *redis.StatusCmd { panic("mock out the Ping method") }, SetFunc: func(key string, value interface{}, expiration time.Duration) *redis.StatusCmd { panic("mock out the Set method") }, } // use mockedRedisClienter in code that requires RedisClienter // and then make assertions. }
func (*RedisClienterMock) ExpireCalls ¶ added in v1.1.0
func (mock *RedisClienterMock) ExpireCalls() []struct { Key string Expiration time.Duration }
ExpireCalls gets all the calls that were made to Expire. Check the length with:
len(mockedRedisClienter.ExpireCalls())
func (*RedisClienterMock) FlushAll ¶ added in v1.1.0
func (mock *RedisClienterMock) FlushAll() *redis.StatusCmd
FlushAll calls FlushAllFunc.
func (*RedisClienterMock) FlushAllCalls ¶ added in v1.1.0
func (mock *RedisClienterMock) FlushAllCalls() []struct { }
FlushAllCalls gets all the calls that were made to FlushAll. Check the length with:
len(mockedRedisClienter.FlushAllCalls())
func (*RedisClienterMock) Get ¶ added in v1.1.0
func (mock *RedisClienterMock) Get(key string) *redis.StringCmd
Get calls GetFunc.
func (*RedisClienterMock) GetCalls ¶ added in v1.1.0
func (mock *RedisClienterMock) GetCalls() []struct { Key string }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedRedisClienter.GetCalls())
func (*RedisClienterMock) Ping ¶ added in v1.1.0
func (mock *RedisClienterMock) Ping() *redis.StatusCmd
Ping calls PingFunc.
func (*RedisClienterMock) PingCalls ¶ added in v1.1.0
func (mock *RedisClienterMock) PingCalls() []struct { }
PingCalls gets all the calls that were made to Ping. Check the length with:
len(mockedRedisClienter.PingCalls())