redis

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nil = redis.Nil
)

Variables

View Source
var ErrNotObtained = redislock.ErrNotObtained

Functions

func CRC16

func CRC16(s string) uint16

Redis CRC16 is a hash function used by Redis to calculate the hash slot for keys in a Redis cluster. The algorithm is based on the CRC16-CCITT polynomial and uses a lookup table to quickly calculate the CRC.

Types

type Config

type Config struct {
	Protocol   string
	Host       string
	Port       string
	Username   string
	Password   string
	DefaultTTL time.Duration
	TLS        TLSConfig
}

type Interface

type Interface interface {
	Get(ctx context.Context, key string) (string, error)
	SetEX(ctx context.Context, key string, val string, expTime time.Duration) error
	Lock(ctx context.Context, key string, expTime time.Duration) (*redislock.Lock, error)
	LockRelease(ctx context.Context, lock *redislock.Lock) error
	Del(ctx context.Context, key string) error
	FlushAll(ctx context.Context) error
	FlushAllAsync(ctx context.Context) error
	FlushDB(ctx context.Context) error
	FlushDBAsync(ctx context.Context) error
	GetDefaultTTL(ctx context.Context) time.Duration
	Ping(ctx context.Context) error
}

func Init

func Init(cfg Config, log logger.Interface) Interface

type Locker

type Locker *redislock.Lock

type TLSConfig

type TLSConfig struct {
	Enabled            bool
	InsecureSkipVerify bool
}

Jump to

Keyboard shortcuts

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