Documentation
¶
Index ¶
- Constants
- type CacheRedis
- func (cache *CacheRedis) Close()
- func (cache *CacheRedis) Exists(ctx context.Context, key string) bool
- func (cache *CacheRedis) ExistsMap(ctx context.Context, key, col string) bool
- func (cache *CacheRedis) ExistsMulti(ctx context.Context, keys ...string) (bool, int64)
- func (cache *CacheRedis) Get(ctx context.Context, key string) (interface{}, error)
- func (cache *CacheRedis) GetMap(ctx context.Context, key, col string) (interface{}, error)
- func (cache *CacheRedis) InitCache() error
- func (cache *CacheRedis) Ping() error
- func (cache *CacheRedis) Set(ctx context.Context, key string, value interface{}, exp time.Duration) error
- func (cache *CacheRedis) SetEntity(ctx context.Context, key string, e entities.Entitable, exp time.Duration) error
- func (cache *CacheRedis) SetMap(ctx context.Context, kv map[string]interface{}) error
- type Connection
- type ConnectionConfig
Constants ¶
View Source
const ( DefaultHost = "localhost" DefaultPort = 6379 DefaultPassword = "" DefaultDB = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheRedis ¶
func NewCache ¶
func NewCache(config *ConnectionConfig) *CacheRedis
func (*CacheRedis) Close ¶
func (cache *CacheRedis) Close()
func (*CacheRedis) ExistsMap ¶
func (cache *CacheRedis) ExistsMap(ctx context.Context, key, col string) bool
func (*CacheRedis) ExistsMulti ¶
func (*CacheRedis) Get ¶
func (cache *CacheRedis) Get(ctx context.Context, key string) (interface{}, error)
func (*CacheRedis) GetMap ¶
func (cache *CacheRedis) GetMap(ctx context.Context, key, col string) (interface{}, error)
func (*CacheRedis) InitCache ¶
func (cache *CacheRedis) InitCache() error
func (*CacheRedis) Ping ¶
func (cache *CacheRedis) Ping() error
type Connection ¶
type Connection struct { DB *redis.Client Config *ConnectionConfig // contains filtered or unexported fields }
Connection Структура для соединения с Redis
func NewConnection ¶
func NewConnection(config *ConnectionConfig) *Connection
NewConnection Возвращает подключение к Redis
func (*Connection) BackgroundCheckConnect ¶
func (conn *Connection) BackgroundCheckConnect()
BackgroundCheckConnect Метод, который через указанное в конфиге время проверяет подключение к Redis
func (*Connection) Close ¶
func (conn *Connection) Close()
Close Закрывает открытое соединение с Redis
type ConnectionConfig ¶
type ConnectionConfig struct { Host string // localhost Port uint16 // 6379 Password string Database int ConnectAttempts int8 // максимальное количество попыток подключения (по-умолчанию 10) ConnectDelay uint8 // задержка перед повторным подключением в секундах (по-умолчанию 10) BackgroundCheckConnectDelay uint8 // по-умолчанию 10 }
func NewRedisConfig ¶
func NewRedisConfig() *ConnectionConfig
func (*ConnectionConfig) GetDSN ¶
func (config *ConnectionConfig) GetDSN() string
Возвращает строку подключения к Redis
Click to show internal directories.
Click to hide internal directories.