cache

package
v0.0.0-...-299d4c7 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(key interface{})

Delete deletes the value for a key.

func Load

func Load(key interface{}) (value interface{}, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func LoadAndDelete

func LoadAndDelete(key interface{}) (value interface{}, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func LoadOrStore

func LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.

func Range

func Range(f func(key, value interface{}) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func RedisCloseSubscribe

func RedisCloseSubscribe() error

RedisCloseSubscribe close

func RedisClusterInfo

func RedisClusterInfo() (string, error)

RedisClusterInfo redis cluster info

func RedisDel

func RedisDel(keys ...string) (int64, error)

RedisDel delete keys from cache

func RedisGet

func RedisGet(k string) (string, error)

RedisGet get value from cache

func RedisInfo

func RedisInfo(section ...string) (string, error)

RedisInfo redis info

func RedisPublish

func RedisPublish(channel string, message interface{}) (int64, error)

Publish posts the message to the channel.

func RedisReceiveSubscribeMessage

func RedisReceiveSubscribeMessage() (channel, message string, err error)

RedisReceiveSubscribeMessage returns a Message or error ignoring Subscription and Pong messages. This is low-level API and in most cases Channel should be used instead.

func RedisReconnect

func RedisReconnect() (string, error)

RedisReconnect re connect

func RedisSet

func RedisSet(k, v string, expiration time.Duration) (string, error)

RedisSet key-value to cache

func RedisSubscribe

func RedisSubscribe(channels ...string) error

Subscribe subscribes the client to the specified channels.

func RedisUnsubscribe

func RedisUnsubscribe(channels ...string) error

Unsubscribe the client from the given channels, or from all of them if none is given.

func SetDefaultRedisClusterOption

func SetDefaultRedisClusterOption(opt RedisClusterOptions) (err error)

SetDefaultRedisClusterOption set default cluster option

func SetDefaultRedisOption

func SetDefaultRedisOption(opt RedisOptions) (err error)

SetDefaultRedisOption set default option

func Store

func Store(key, value interface{})

Store sets the value for a key.

Types

type RedisCache

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

RedisCache define

func NewRedisCache

func NewRedisCache(opt RedisOptions) (rc *RedisCache, err error)

NewRedisCache new RedisCache object

func NewRedisClusterCache

func NewRedisClusterCache(opt RedisClusterOptions) (rc *RedisCache, err error)

NewRedisClusterCache new RedisCluster object

func (*RedisCache) CloseSubscribe

func (c *RedisCache) CloseSubscribe() error

CloseSubscribe close

func (RedisCache) ClusterInfo

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

ClusterInfo redis cluster info

func (RedisCache) Del

func (c RedisCache) Del(ks ...string) (int64, error)

Del delete key from cache

func (RedisCache) Get

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

Get get value from cache

func (RedisCache) Info

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

Info redis info

func (RedisCache) Publish

func (c RedisCache) Publish(channel string, message interface{}) (int64, error)

Publish posts the message to the channel.

func (*RedisCache) ReceiveSubscribeMessage

func (c *RedisCache) ReceiveSubscribeMessage() (channel, message string, err error)

ReceiveSubscribeMessage returns a Message or error ignoring Subscription and Pong messages. This is low-level API and in most cases Channel should be used instead.

func (RedisCache) Reconnect

func (c RedisCache) Reconnect() (s string, err error)

Reconnect reconnect

func (RedisCache) Set

func (c RedisCache) Set(k, v string, expiration time.Duration) (string, error)

Set key-value to cache

func (*RedisCache) Subscribe

func (c *RedisCache) Subscribe(channels ...string) error

Subscribe subscribes the client to the specified channels.

func (*RedisCache) Unsubscribe

func (c *RedisCache) Unsubscribe(channels ...string) error

Unsubscribe the client from the given channels, or from all of them if none is given.

type RedisClusterOptions

type RedisClusterOptions struct {
	DB         int
	PoolSize   int
	MaxRetries int

	MinRetryBackoff time.Duration
	MaxRetryBackoff time.Duration

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

	PoolTimeout        time.Duration
	IdleTimeout        time.Duration
	IdleCheckFrequency time.Duration

	Password string
	Addrs    []string
}

RedisClusterOptions cluster option

type RedisOptions

type RedisOptions struct {
	DB       int
	PoolSize int

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

	Password string
	Addr     string
}

RedisOptions options

Jump to

Keyboard shortcuts

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