Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Checker(ctx context.Context, state *health.CheckState) error
- func (c *Client) DeleteAll() error
- func (c *Client) Expire(key string, expiration time.Duration) error
- func (c *Client) GetByEmail(email string) (*session.Session, error)
- func (c *Client) GetByID(id string) (*session.Session, error)
- func (c *Client) Ping() error
- func (c *Client) SetSession(s *session.Session) error
- type Config
- 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{ ... }
Constants ¶
View Source
const HealthyMessage = "redis is OK"
Variables ¶
View Source
var ( 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") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client - structure for the redis client
func (*Client) GetByEmail ¶ added in v1.0.0
GetByEmail - gets a session from redis using its ID
type RedisClienter ¶
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 ¶
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 ¶
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 ¶
func (mock *RedisClienterMock) FlushAll() *redis.StatusCmd
FlushAll calls FlushAllFunc.
func (*RedisClienterMock) FlushAllCalls ¶
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 ¶
func (mock *RedisClienterMock) Get(key string) *redis.StringCmd
Get calls GetFunc.
func (*RedisClienterMock) GetCalls ¶
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 ¶
func (mock *RedisClienterMock) Ping() *redis.StatusCmd
Ping calls PingFunc.
func (*RedisClienterMock) PingCalls ¶
func (mock *RedisClienterMock) PingCalls() []struct { }
PingCalls gets all the calls that were made to Ping. Check the length with:
len(mockedRedisClienter.PingCalls())
Click to show internal directories.
Click to hide internal directories.