memcache

package module
v2.0.0-...-74eeffd Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(opts ...Option) *Cache

func (*Cache) AddPrefix

func (c *Cache) AddPrefix(key string) string

AddPrefix 添加Key前缀

func (*Cache) Client

func (c *Cache) Client() interface{}

Client 获取客户端

func (*Cache) Close

func (c *Cache) Close() error

Close 关闭客户端

func (*Cache) DecrFloat

func (c *Cache) DecrFloat(ctx context.Context, key string, value float64) (float64, error)

DecrFloat 浮点数自减

func (*Cache) DecrInt

func (c *Cache) DecrInt(ctx context.Context, key string, value int64) (int64, error)

DecrInt 整数自减

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) (bool, error)

Delete 删除缓存

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string, def ...interface{}) cache.Result

Get 获取缓存值

func (*Cache) GetSet

func (c *Cache) GetSet(ctx context.Context, key string, fn cache.SetValueFunc) cache.Result

GetSet 获取设置缓存值

func (*Cache) Has

func (c *Cache) Has(ctx context.Context, key string) (bool, error)

Has 检测缓存是否存在

func (*Cache) IncrFloat

func (c *Cache) IncrFloat(ctx context.Context, key string, value float64) (float64, error)

IncrFloat 浮点数自增

func (*Cache) IncrInt

func (c *Cache) IncrInt(ctx context.Context, key string, value int64) (int64, error)

IncrInt 整数自增

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, value interface{}, expiration ...time.Duration) error

Set 设置缓存值

type Option

type Option func(o *options)

func WithAddrs

func WithAddrs(addrs ...string) Option

WithAddrs 设置连接地址

func WithClient

func WithClient(client *memcache.Client) Option

WithClient 设置外部客户端

func WithNilExpiration

func WithNilExpiration(nilExpiration time.Duration) Option

WithNilExpiration 设置空值过期时间

func WithNilValue

func WithNilValue(nilValue string) Option

WithNilValue 设置空值

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix 设置前缀

Jump to

Keyboard shortcuts

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