cache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RedisNil = fmt.Sprintf("redis: nil")

Functions

This section is empty.

Types

type Cache

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

采用json进行序列化的的cache

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 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 (*RedisClient) Del

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

func (*RedisClient) Get

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

func (*RedisClient) Incr

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

func (*RedisClient) Set

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

func (*RedisClient) SetNX

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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