cache

package
v0.0.0-...-34dd132 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Del

func Del(key string) (int64, error)

Del delete key from cache

func Get

func Get(key string) (string, error)

Get key from cache

func Info

func Info() (string, error)

Info info

func Ping

func Ping() (string, error)

Ping ping

func Publish

func Publish(channel, message string) error

Publish publish message

func Set

func Set(key, value string, expiration time.Duration) error

Set key-value to cache

func SetRedisClusterConfig

func SetRedisClusterConfig(cfg RedisClusterConfig)

SetRedisClusterConfig set

func SetRedisConfig

func SetRedisConfig(cfg RedisConfig)

SetRedisConfig set

func Subscribe

func Subscribe(channels string, cb func(channel string, message string, err error)) error

Types

type RedisCache

type RedisCache struct {
	// contains filtered or unexported fields
}

RedisCache define

func NewRedisCache

func NewRedisCache() *RedisCache

NewRedisCache new RedisCache object

func NewRedisClusterCache

func NewRedisClusterCache() *RedisCache

NewRedisClusterCache new RedisCluster object

func (RedisCache) Del

func (c RedisCache) Del(key string) (int64, error)

Del Del value from cache

func (RedisCache) Get

func (c RedisCache) Get(key string) (string, error)

Get get value from cache

func (RedisCache) Info

func (c RedisCache) Info() (string, error)

Info info

func (RedisCache) Ping

func (c RedisCache) Ping() (string, error)

Get get value from cache

func (RedisCache) Publish

func (c RedisCache) Publish(channel, message string) error

Publish publish message

func (RedisCache) Set

func (c RedisCache) Set(key, value string, expiration time.Duration) error

Set set key-value to cache

func (RedisCache) Subscribe

func (c RedisCache) Subscribe(channels string, cb func(channel string, message string, err error)) error

Subscribe subscribe message

type RedisClusterConfig

type RedisClusterConfig struct {
	// A seed list of host:port addresses of cluster nodes.
	Addrs []string

	Password string
	DB       int

	// The maximum number of retries before giving up. Command is retried
	// on network errors and MOVED/ASK redirects.
	// Default is 16.
	MaxRedirects int

	// Enables read-only commands on slave nodes.
	ReadOnly bool
	// Allows routing read-only commands to the closest master or slave node.
	RouteByLatency bool

	MaxRetries      int
	MinRetryBackoff time.Duration
	MaxRetryBackoff time.Duration

	DialTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration

	// PoolSize applies per cluster node and not for the whole cluster.
	PoolSize           int
	PoolTimeout        time.Duration
	IdleTimeout        time.Duration
	IdleCheckFrequency time.Duration
}

RedisClusterConfig redis cluster configure

type RedisConfig

type RedisConfig struct {
	Addr         string
	Password     string
	DB           int
	DialTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	PoolTimeout  time.Duration
	PoolSize     int
}

RedisConfig config

Jump to

Keyboard shortcuts

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