redis

package
v0.0.0-...-58e3b6f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost     = "localhost"
	DefaultPort     = 6379
	DefaultPassword = ""
	DefaultDB       = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheRedis

type CacheRedis struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCache

func NewCache(config *ConnectionConfig) *CacheRedis

func (*CacheRedis) Close

func (cache *CacheRedis) Close()

func (*CacheRedis) Exists

func (cache *CacheRedis) Exists(ctx context.Context, key string) bool

func (*CacheRedis) ExistsMap

func (cache *CacheRedis) ExistsMap(ctx context.Context, key, col string) bool

func (*CacheRedis) ExistsMulti

func (cache *CacheRedis) ExistsMulti(ctx context.Context, keys ...string) (bool, int64)

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

func (*CacheRedis) Set

func (cache *CacheRedis) Set(ctx context.Context, key string, value interface{}, exp time.Duration) error

func (*CacheRedis) SetEntity

func (cache *CacheRedis) SetEntity(ctx context.Context, key string, e entities.Entitable, exp time.Duration) error

func (*CacheRedis) SetMap

func (cache *CacheRedis) SetMap(ctx context.Context, kv map[string]interface{}) 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

func (*Connection) Open

func (conn *Connection) Open() error

Open Подключение к Redis

func (*Connection) Ping

func (conn *Connection) Ping() error

Ping Проверка подключения к 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL