redis

package
v0.0.0-...-66cf1cd Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package redis @program: gin-template @author: [lliuhuan](https://github.com/lliuhuan) @create: 2024-07-03 09:44

Index

Constants

View Source
const (
	// ClusterMode using clusterClient
	ClusterMode string = "cluster"
	// SimpleMode using Client
	SimpleMode string = "simple"
	// FailoverMode using Failover sentinel client
	FailoverMode string = "failover"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(cfg configs.Redis) (redis.UniversalClient, error)

NewClient 默认使用Simple模式

func NewClusterClient

func NewClusterClient(cfg configs.Redis) (redis.UniversalClient, error)

NewClusterClient 集群模式

func NewFailoverClient

func NewFailoverClient(cfg configs.Redis) (redis.UniversalClient, error)

NewFailoverClient 创建哨兵模式

Types

type Option

type Option func(*option)

func WithTrace

func WithTrace(t Trace) Option

WithTrace 设置trace信息

type Repo

type Repo interface {
	Set(key, value string, ttl time.Duration, options ...Option) error
	Get(key string, options ...Option) (string, error)
	TTL(key string) (time.Duration, error)
	Expire(key string, ttl time.Duration) bool
	ExpireAt(key string, ttl time.Time) bool
	Del(key string, options ...Option) bool
	Exists(keys ...string) bool
	Incr(key string, options ...Option) int64
	Close() error
	Version() string
	// contains filtered or unexported methods
}

func New

func New() (Repo, error)

type Trace

type Trace = trace.T

Jump to

Keyboard shortcuts

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