versioncache

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MIT, MIT Imports: 4 Imported by: 0

README

VersionCache 基于版本的远程缓存驱动

基于版本的本地、远程缓存驱动,通过将大体积数据储存在本地提升效率的缓存结构。一般在需要多进程/多机使用缓存时提升效率

配置说明

#TOML版本,其他版本可以根据对应格式配置
#本地缓存配置
"Local.Driver"="syncmapcache"
"Local.TTL"="1800"
"Local.Config.Size"=5000000
#远程缓存配置
"Remote.Driver"="freecache"
"Remote.TTL"="1800"
"Remote.Config.Size"=5000000

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrVersionFormatWrong = errors.New("error version format wrong")

ErrVersionFormatWrong raised when version format wrong

Functions

This section is empty.

Types

type Cache

type Cache struct {
	cache.DriverUtil
	Local  *cache.Cache
	Remote *cache.Cache
}

Cache The redis cache Driver.

func (*Cache) Close

func (c *Cache) Close() error

Close Close cache. Return any error if raised

func (*Cache) Del

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

Del Delete data in cache by given key. Return any error raised.

func (*Cache) DelCounter

func (c *Cache) DelCounter(key string) error

DelCounter Delete int val in cache by given key.Count cache and data cache are in two independent namespace. Return any error raised.

func (*Cache) Expire

func (c *Cache) Expire(key string, ttl time.Duration) error

Expire set cache value expire duration by given key and ttl

func (*Cache) ExpireCounter

func (c *Cache) ExpireCounter(key string, ttl time.Duration) error

ExpireCounter set cache counter expire duration by given key and ttl

func (*Cache) Flush

func (c *Cache) Flush() error

Flush Flush not supported.

func (*Cache) GetBytesValue

func (c *Cache) GetBytesValue(key string) ([]byte, error)

GetBytesValue Get bytes data from cache by given key. Return data bytes and any error raised.

func (*Cache) GetCounter

func (c *Cache) GetCounter(key string) (int64, error)

GetCounter Get int val from cache by given key.Count cache and data cache are in two independent namespace. Return int data value and any error raised.

func (*Cache) IncrCounter

func (c *Cache) IncrCounter(key string, increment int64, ttl time.Duration) (int64, error)

IncrCounter Increase int val in cache by given key.Count cache and data cache are in two independent namespace. Return int data value and any error raised.

func (*Cache) MGetBytesValue

func (c *Cache) MGetBytesValue(keys ...string) (map[string][]byte, error)

MGetBytesValue get multiple bytes data from cache by given keys. Return data bytes map and any error if raised.

func (*Cache) MSetBytesValue

func (c *Cache) MSetBytesValue(data map[string][]byte, ttl time.Duration) error

MSetBytesValue set multiple bytes data to cache with given key-value map. Return any error if raised.

func (*Cache) SetBytesValue

func (c *Cache) SetBytesValue(key string, bytes []byte, ttl time.Duration) error

SetBytesValue Set bytes data to cache by given key. Return any error raised.

func (*Cache) SetCounter

func (c *Cache) SetCounter(key string, v int64, ttl time.Duration) error

SetCounter Set int val in cache by given key.Count cache and data cache are in two independent namespace. Return any error raised.

func (*Cache) SetGCErrHandler

func (c *Cache) SetGCErrHandler(f func(err error))

SetGCErrHandler Set callback to handler error raised when gc.

func (*Cache) UpdateBytesValue

func (c *Cache) UpdateBytesValue(key string, bytes []byte, ttl time.Duration) error

UpdateBytesValue Update bytes data to cache by given key only if the cache exist. Return any error raised.

type Config

type Config struct {
	Local  cache.Config
	Remote cache.Config
}

Config Cache driver config.

Jump to

Keyboard shortcuts

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