cache

package
v1.4.13 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpanLogKeyKey    = "key"
	SpanLogCacheType = "cache"
	SpanLogOp        = "op"
)
View Source
const (
	WrapperTypeCache    = "c"
	WrapperTypeRedisExt = "e"
)
View Source
const DefaultRouteGroup = "default"

Variables

This section is empty.

Functions

func SetConfiger

func SetConfiger(ctx context.Context, configerType constants.ConfigerType) error

func WatchUpdate

func WatchUpdate(ctx context.Context)

Types

type Cache

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

采用json进行序列化的的cache

func NewCacheByNamespace

func NewCacheByNamespace(ctx context.Context, namespace, prefix string, expire int) (*Cache, error)

func NewCommonCache

func NewCommonCache(serverName, prefix string, poolSize, expire int) (*Cache, error)

redis 地址列表,key前缀,过期时间

func NewCoreCache

func NewCoreCache(serverName, prefix string, poolSize, expire int) (*Cache, error)

func (*Cache) Del

func (m *Cache) Del(key string) error

func (*Cache) Get

func (m *Cache) Get(key string, data CacheData) error

func (*Cache) GetCache

func (m *Cache) GetCache(key string, data CacheData) error

func (*Cache) Set

func (m *Cache) Set(key string, data CacheData) error

type CacheData

type CacheData interface {
	// 序列化接口
	Marshal() ([]byte, error)
	// 反序列化接口
	Unmarshal([]byte) error
	// cache miss load数据接口
	Load(key string) error
}

type CacheType

type CacheType int
const (
	CacheTypeRedis CacheType = iota
)

func (CacheType) String

func (t CacheType) String() string

type ConfigerType

type ConfigerType int
const (
	ConfigerTypeSimple ConfigerType = iota
	ConfigerTypeEtcd
	ConfigerTypeApollo
)

func (ConfigerType) String

func (c ConfigerType) String() string

type RedisClient

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

func NewCommonRedis

func NewCommonRedis(serverName string, poolSize int) (*RedisClient, error)

func NewCoreRedis

func NewCoreRedis(serverName string, poolSize int) (*RedisClient, error)

func NewRedisByAddr added in v1.4.13

func NewRedisByAddr(addr, serverName string, poolSize int) (*RedisClient, error)

NewRedisByAddr ...

func NewRedisByNamespace

func NewRedisByNamespace(ctx context.Context, namespace string) (*RedisClient, error)

func (*RedisClient) Del

func (m *RedisClient) Del(keys ...string) *go_redis.IntCmd

func (*RedisClient) Expire

func (m *RedisClient) Expire(key string, expiration time.Duration) *go_redis.BoolCmd

func (*RedisClient) Get

func (m *RedisClient) Get(key string) *go_redis.StringCmd

func (*RedisClient) Incr

func (m *RedisClient) Incr(key string) *go_redis.IntCmd

func (*RedisClient) Set

func (m *RedisClient) Set(key string, value interface{}, expiration time.Duration) *go_redis.StatusCmd

func (*RedisClient) SetNX

func (m *RedisClient) SetNX(key string, value interface{}, expiration time.Duration) *go_redis.BoolCmd

func (*RedisClient) TTL

func (m *RedisClient) TTL(key string) *go_redis.DurationCmd

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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