xmemcache

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

README

clients

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTracingHook

func NewTracingHook() *tracingHook

Types

type Hook

type Hook interface {
	Before(context.Context, string, ...string) (context.Context, error)
	After(context.Context, error)
}

type MemcacheProxy

type MemcacheProxy struct {
	Opt *Option
	// contains filtered or unexported fields
}

MemcacheProxy memcache 三方包的包装器类

func New

func New(opt *Option, logger xlog.Logger, metrics metrics.Provider, tracer tracer.Provider) (*MemcacheProxy, error)

func (*MemcacheProxy) AddHook

func (mp *MemcacheProxy) AddHook(h Hook)

func (*MemcacheProxy) Delete

func (m *MemcacheProxy) Delete(ctx context.Context, key string) error

Delete 删除操作

func (*MemcacheProxy) Destory

func (mp *MemcacheProxy) Destory() error

func (*MemcacheProxy) Get

func (m *MemcacheProxy) Get(ctx context.Context, key string) (string, error)

Get 根据Key获取缓存数值

func (*MemcacheProxy) Initialize

func (mp *MemcacheProxy) Initialize() error

func (*MemcacheProxy) MGet

func (m *MemcacheProxy) MGet(ctx context.Context, keys []string) (map[string]string, error)

MGet 获取多个数值

func (*MemcacheProxy) Set

func (m *MemcacheProxy) Set(ctx context.Context, key string, value string) error

Set 设置缓存

func (*MemcacheProxy) SetWithExpire

func (m *MemcacheProxy) SetWithExpire(ctx context.Context, key string, value string, expire int) error

SetWithExpire 设置缓存,并且添加超时 expire 以s为单位

func (*MemcacheProxy) WithLogger

func (mp *MemcacheProxy) WithLogger(logger xlog.Logger)

func (*MemcacheProxy) WithMetrics

func (mp *MemcacheProxy) WithMetrics(metrics metrics.Provider)

type Option

type Option struct {
	Name         string        // 客户端名称,需要唯一
	Timeout      time.Duration // 客户端连接超时时间
	MaxIdleConns int           // 最大空闲连接
	Addr         []string      // 集群地址
	EnableTracer bool
}

Options 可配置的数据

Jump to

Keyboard shortcuts

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