rdscache

package
v0.0.0-...-c6def77 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

README

rdscache

-- import "github.com/wencan/cachex/rdscache"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Marshal 数据序列化函数
	Marshal = msgpack.Marshal

	// Unmarshal 数据反序列化函数
	Unmarshal = msgpack.Unmarshal
)

Functions

This section is empty.

Types

type NotFound

type NotFound struct{}

NotFound 没找到错误

func (NotFound) Error

func (NotFound) Error() string

func (NotFound) NotFound

func (NotFound) NotFound()

NotFound 实现cachex.NotFound错误接口

type PoolConfig

type PoolConfig struct {
	Dial func(network, addr string) (net.Conn, error)

	DB int

	Password string

	MaxIdle int

	MaxActive int

	IdleTimeout time.Duration

	Wait bool

	MaxConnLifetime time.Duration
}

PoolConfig redis池连接参数

type RdsCache

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

RdsCache redis存储实现

func NewRdsCache

func NewRdsCache(ctx context.Context, network, address string, poolCfg PoolConfig, options ...RdsOption) *RdsCache

NewRdsCache 创建redis缓存对象 内部创建redis连接池

func NewRdsCacheWithPool

func NewRdsCacheWithPool(rdsPool *redis.Pool, options ...RdsOption) *RdsCache

NewRdsCacheWithPool 创建redis缓存对象 使用现有redis连接池

func (*RdsCache) Del

func (c *RdsCache) Del(ctx context.Context, keys ...interface{}) error

Del 删除缓存数据

func (*RdsCache) Get

func (c *RdsCache) Get(ctx context.Context, key, value interface{}) error

Get 获取缓存数据

func (*RdsCache) Set

func (c *RdsCache) Set(ctx context.Context, key, value interface{}) error

Set 设置缓存数据

func (*RdsCache) SetWithTTL

func (c *RdsCache) SetWithTTL(ctx context.Context, key, value interface{}, TTL time.Duration) error

SetWithTTL 设置缓存数据,并定制TTL

type RdsOption

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

RdsOption rdscache配置

func RdsDefaultTTLOption

func RdsDefaultTTLOption(defaultTTL time.Duration) RdsOption

RdsDefaultTTLOption 配置key默认生存时间

func RdsKeyPrefixOption

func RdsKeyPrefixOption(keyPrefix string) RdsOption

RdsKeyPrefixOption 配置key前缀

Jump to

Keyboard shortcuts

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