gofcache

package
v0.0.0-...-40c044f Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefCache         CacheInterface
	RedisGlobalCache *RedisCache
	MeCache          *MemoryCache
)

DefCache ...

Functions

func InitCache

func InitCache()

Types

type CacheInterface

type CacheInterface interface {
	Get(key string) ([]byte, error)
	//if cannot get value,return 0
	GetInt64(key string) (int64, error)
	//return "" if can't get value
	GetValue(key string) (string, error)
	//bind value to struct point
	Bind(key string, bean interface{}) error
	Set(key string, value interface{}, exp time.Duration) error
	Remember(key string, set func() error) ([]byte, error)
	RememberBind(key string, bean interface{}, set func() error) error
	Exists(key string) bool
	Del(key string) error
	DelAll() error
}

CacheInterface ... 缓存接口

type MemoryCache

type MemoryCache struct {
	Client *buntdb.DB
	// contains filtered or unexported fields
}

MemoryCache ...

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache ...

func (*MemoryCache) Bind

func (m *MemoryCache) Bind(key string, bean interface{}) error

Bind ...

func (*MemoryCache) Del

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

Del ...

func (*MemoryCache) DelAll

func (m *MemoryCache) DelAll() error

DelAll ...

func (*MemoryCache) Exists

func (m *MemoryCache) Exists(key string) bool

Exists ...

func (*MemoryCache) Get

func (m *MemoryCache) Get(key string) ([]byte, error)

Get ...

func (*MemoryCache) GetInt64

func (m *MemoryCache) GetInt64(key string) (i int64, err error)

GetInt64 ...

func (*MemoryCache) GetValue

func (m *MemoryCache) GetValue(key string) (string, error)

GetValue ...

func (*MemoryCache) Remember

func (m *MemoryCache) Remember(key string, set func() error) (b []byte, err error)

Remember ...

func (*MemoryCache) RememberBind

func (m *MemoryCache) RememberBind(key string, bean interface{}, set func() error) error

RememberBind ...

func (*MemoryCache) Set

func (m *MemoryCache) Set(key string, value interface{}, exp time.Duration) error

Set ...

type RedisCache

type RedisCache struct {
	Client *redis.Client
	// contains filtered or unexported fields
}

RedisCache ...

func NewRedisCache

func NewRedisCache() *RedisCache

NewRedisCache ...

func (*RedisCache) Bind

func (r *RedisCache) Bind(key string, bean interface{}) error

Bind ...

func (*RedisCache) Del

func (r *RedisCache) Del(key string) error

Del ...

func (*RedisCache) DelAll

func (r *RedisCache) DelAll() error

DelAll ...

func (*RedisCache) Exists

func (r *RedisCache) Exists(key string) bool

Exists ...

func (*RedisCache) Get

func (r *RedisCache) Get(key string) (b []byte, err error)

Get ...

func (*RedisCache) GetInt64

func (r *RedisCache) GetInt64(key string) (int64, error)

GetInt64 ...

func (*RedisCache) GetValue

func (r *RedisCache) GetValue(key string) (string, error)

GetValue ...

func (*RedisCache) JSONSet

func (r *RedisCache) JSONSet(key string, value interface{}, exp time.Duration) error

JSONSet ... 将一个对象序列化成 json 字符串,并进行存储

func (*RedisCache) Remember

func (r *RedisCache) Remember(key string, set func() error) (b []byte, err error)

Remember ...

func (*RedisCache) RememberBind

func (r *RedisCache) RememberBind(key string, bean interface{}, set func() error) error

RememberBind ...

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value interface{}, exp time.Duration) error

Set write operation,and need lock

Jump to

Keyboard shortcuts

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