cache

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const VersionName = "0.1.0"

Variables

This section is empty.

Functions

func Register

func Register(name string, store Store)

Register registers a store.

func Version

func Version() string

Types

type AdapterConfig

type AdapterConfig struct {
	Addr     string
	Password string
	DB       int
}

type Cache

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

func NewCache

func NewCache(options Options) (*Cache, error)

func (*Cache) Client added in v0.5.1

func (this *Cache) Client() interface{}

func (*Cache) Close added in v1.2.1

func (this *Cache) Close() error

func (*Cache) Decr

func (this *Cache) Decr(key string) (int64, error)

func (*Cache) Del added in v1.0.6

func (this *Cache) Del(keys ...string) (int64, error)

func (*Cache) Delete

func (this *Cache) Delete(key string) error

func (*Cache) DeleteByPrefix

func (this *Cache) DeleteByPrefix(prefix string) error

func (*Cache) Exist added in v1.0.6

func (this *Cache) Exist(key string) bool

func (*Cache) Exists added in v1.0.6

func (this *Cache) Exists(keys ...string) (int64, error)

func (*Cache) Expire added in v1.0.6

func (this *Cache) Expire(key string, expiration time.Duration) (bool, error)

func (*Cache) Flush

func (this *Cache) Flush() error

func (*Cache) Get

func (this *Cache) Get(key string) (string, error)

func (*Cache) HDel added in v1.0.6

func (this *Cache) HDel(key string, fields ...string) (int64, error)

func (*Cache) HExists added in v1.0.6

func (this *Cache) HExists(key, field string) (bool, error)

func (*Cache) HGet added in v1.0.6

func (this *Cache) HGet(key, field string) (string, error)

func (*Cache) HGetAll added in v1.0.6

func (this *Cache) HGetAll(key string) (map[string]string, error)

func (*Cache) HMGet added in v1.0.6

func (this *Cache) HMGet(key string, fields ...string) ([]interface{}, error)

func (*Cache) HMSet added in v1.0.6

func (this *Cache) HMSet(key string, values ...interface{}) (bool, error)

func (*Cache) HSet added in v1.0.6

func (this *Cache) HSet(key string, values ...interface{}) (int64, error)

func (*Cache) HSetNX added in v1.0.6

func (this *Cache) HSetNX(key, field string, value interface{}) (bool, error)

func (*Cache) Incr

func (this *Cache) Incr(key string) (int64, error)

func (*Cache) Key added in v0.5.2

func (this *Cache) Key(key string) string

func (*Cache) LLen added in v1.0.6

func (this *Cache) LLen(key string) (int64, error)

func (*Cache) LPush added in v1.0.6

func (this *Cache) LPush(key string, values ...interface{}) (int64, error)

func (*Cache) LRange added in v1.0.6

func (this *Cache) LRange(key string, start, stop int64) ([]string, error)

func (*Cache) SAdd added in v1.0.6

func (this *Cache) SAdd(key string, members ...interface{}) (int64, error)

func (*Cache) SCard added in v1.0.6

func (this *Cache) SCard(key string) (int64, error)

func (*Cache) SRem added in v1.0.6

func (this *Cache) SRem(key string, members ...interface{}) (int64, error)

func (*Cache) SScan added in v1.0.6

func (this *Cache) SScan(key string, cursor uint64, match string, count int64) ([]string, uint64, error)

func (*Cache) Set

func (this *Cache) Set(key, val string, expiration time.Duration) error

func (*Cache) SetEX added in v1.0.6

func (this *Cache) SetEX(key string, value interface{}, expiration time.Duration) (string, error)

func (*Cache) SetNX added in v1.0.6

func (this *Cache) SetNX(key string, value interface{}, expiration time.Duration) (bool, error)

func (*Cache) TTL added in v1.0.6

func (this *Cache) TTL(key string) (time.Duration, error)

func (*Cache) Touch

func (this *Cache) Touch(key string) error

func (*Cache) Type added in v1.0.6

func (this *Cache) Type(key string) (string, error)

func (*Cache) ZAdd added in v1.0.6

func (this *Cache) ZAdd(key string, members ...*redis.Z) (int64, error)

func (*Cache) ZRange added in v1.0.6

func (this *Cache) ZRange(key string, start, stop int64) ([]string, error)

func (*Cache) ZRank added in v1.0.6

func (this *Cache) ZRank(key, member string) (int64, error)

func (*Cache) ZRem added in v1.0.6

func (this *Cache) ZRem(key string, members ...interface{}) (int64, error)

func (*Cache) ZScore added in v1.0.6

func (this *Cache) ZScore(key, member string) (float64, error)

type MemoryCache

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

MemoryCache represents a memory cache adapter implementation.

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache creates and returns a new memory cache.

func (*MemoryCache) BitCount added in v1.0.7

func (c *MemoryCache) BitCount(key string, bitCount *redis.BitCount) (int64, error)

func (*MemoryCache) BitField added in v1.0.7

func (c *MemoryCache) BitField(key string, args ...interface{}) ([]int64, error)

func (*MemoryCache) BitOpAnd added in v1.0.7

func (c *MemoryCache) BitOpAnd(destKey string, keys ...string) (int64, error)

func (*MemoryCache) BitOpNot added in v1.0.7

func (c *MemoryCache) BitOpNot(destKey string, key string) (int64, error)

func (*MemoryCache) BitOpOr added in v1.0.7

func (c *MemoryCache) BitOpOr(destKey string, keys ...string) (int64, error)

func (*MemoryCache) BitOpXor added in v1.0.7

func (c *MemoryCache) BitOpXor(destKey string, keys ...string) (int64, error)

func (*MemoryCache) BitPos added in v1.0.7

func (c *MemoryCache) BitPos(key string, bit int64, pos ...int64) (int64, error)

func (*MemoryCache) Client added in v0.5.0

func (r *MemoryCache) Client() interface{}

func (*MemoryCache) Close added in v1.2.1

func (c *MemoryCache) Close() error

func (*MemoryCache) Decr

func (c *MemoryCache) Decr(key string) (int64, error)

func (*MemoryCache) Del added in v1.0.5

func (c *MemoryCache) Del(keys ...string) (int64, error)

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(key string) error

func (*MemoryCache) DeleteByPrefix

func (c *MemoryCache) DeleteByPrefix(prefix string) error

func (*MemoryCache) Exist added in v1.0.6

func (c *MemoryCache) Exist(key string) bool

func (*MemoryCache) Exists added in v1.0.5

func (c *MemoryCache) Exists(keys ...string) (int64, error)

func (*MemoryCache) Expire added in v1.0.5

func (c *MemoryCache) Expire(key string, expiration time.Duration) (bool, error)

func (*MemoryCache) Flush

func (c *MemoryCache) Flush() error

func (*MemoryCache) Forever

func (c *MemoryCache) Forever(key, val string) error

Forever put value into cache with key forever save

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) (string, error)

func (*MemoryCache) GetBit added in v1.0.7

func (c *MemoryCache) GetBit(key string, offset int64) (int64, error)

func (*MemoryCache) HDel added in v1.0.5

func (c *MemoryCache) HDel(key string, fields ...string) (int64, error)

func (*MemoryCache) HExists added in v1.0.5

func (c *MemoryCache) HExists(key, field string) (bool, error)

func (*MemoryCache) HGet added in v1.0.5

func (c *MemoryCache) HGet(key, field string) (string, error)

func (*MemoryCache) HGetAll added in v1.0.5

func (c *MemoryCache) HGetAll(key string) (map[string]string, error)

func (*MemoryCache) HMGet added in v1.0.5

func (c *MemoryCache) HMGet(key string, fields ...string) ([]interface{}, error)

func (*MemoryCache) HMSet added in v1.0.5

func (c *MemoryCache) HMSet(key string, values ...interface{}) (bool, error)

func (*MemoryCache) HSet added in v1.0.5

func (c *MemoryCache) HSet(key string, values ...interface{}) (int64, error)

func (*MemoryCache) HSetNX added in v1.0.5

func (c *MemoryCache) HSetNX(key, field string, value interface{}) (bool, error)

func (*MemoryCache) Incr

func (c *MemoryCache) Incr(key string) (int64, error)

func (*MemoryCache) Key added in v0.5.2

func (r *MemoryCache) Key(key string) string

func (*MemoryCache) LLen added in v1.0.5

func (c *MemoryCache) LLen(key string) (int64, error)

func (*MemoryCache) LPush added in v1.0.5

func (c *MemoryCache) LPush(key string, values ...interface{}) (int64, error)

func (*MemoryCache) LRange added in v1.0.5

func (c *MemoryCache) LRange(key string, start, stop int64) ([]string, error)

func (*MemoryCache) RPop added in v1.0.7

func (c *MemoryCache) RPop(key string) (string, error)

func (*MemoryCache) RPopCount added in v1.0.7

func (c *MemoryCache) RPopCount(key string, count int) ([]string, error)

func (*MemoryCache) RPopLPush added in v1.0.7

func (c *MemoryCache) RPopLPush(source, destination string) (string, error)

func (*MemoryCache) RPush added in v1.0.7

func (c *MemoryCache) RPush(key string, values ...interface{}) (int64, error)

func (*MemoryCache) RPushX added in v1.0.7

func (c *MemoryCache) RPushX(key string, values ...interface{}) (int64, error)

func (*MemoryCache) RunScript added in v1.0.7

func (c *MemoryCache) RunScript(src string, keys []string, args ...interface{}) (interface{}, error)

func (*MemoryCache) SAdd added in v1.0.5

func (c *MemoryCache) SAdd(key string, members ...interface{}) (int64, error)

func (*MemoryCache) SCard added in v1.0.5

func (c *MemoryCache) SCard(key string) (int64, error)

func (*MemoryCache) SRem added in v1.0.5

func (c *MemoryCache) SRem(key string, members ...interface{}) (int64, error)

func (*MemoryCache) SScan added in v1.0.5

func (c *MemoryCache) SScan(key string, cursor uint64, match string, count int64) ([]string, uint64, error)

func (*MemoryCache) Set

func (c *MemoryCache) Set(key, val string, expiration time.Duration) error

func (*MemoryCache) SetBit added in v1.0.7

func (c *MemoryCache) SetBit(key string, offset int64, value int) (int64, error)

func (*MemoryCache) SetEX added in v1.0.5

func (c *MemoryCache) SetEX(key string, value interface{}, expiration time.Duration) (string, error)

func (*MemoryCache) SetNX added in v1.0.5

func (c *MemoryCache) SetNX(key string, value interface{}, expiration time.Duration) (bool, error)

func (*MemoryCache) TTL added in v1.0.5

func (c *MemoryCache) TTL(key string) (time.Duration, error)

func (*MemoryCache) Touch

func (c *MemoryCache) Touch(key string) error

func (*MemoryCache) Type added in v1.0.5

func (c *MemoryCache) Type(key string) (string, error)

func (*MemoryCache) ZAdd added in v1.0.5

func (c *MemoryCache) ZAdd(key string, members ...*redis.Z) (int64, error)

func (*MemoryCache) ZRange added in v1.0.5

func (c *MemoryCache) ZRange(key string, start, stop int64) ([]string, error)

func (*MemoryCache) ZRank added in v1.0.5

func (c *MemoryCache) ZRank(key, member string) (int64, error)

func (*MemoryCache) ZRem added in v1.0.5

func (c *MemoryCache) ZRem(key string, members ...interface{}) (int64, error)

func (*MemoryCache) ZScore added in v1.0.5

func (c *MemoryCache) ZScore(key, member string) (float64, error)

type MemoryItem

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

MemoryItem represents a memory cache item.

type Options

type Options struct {
	// alias
	Alias string
	// Name of adapter. Default is "redis".
	Adapter string
	// Adapter configuration, it's corresponding to adapter.
	AdapterConfig AdapterConfig
	// key prefix Default is ""
	Section string
}

type RedisCache

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

func NewRedisCache

func NewRedisCache() *RedisCache

NewRedisCache creates and returns a new redis cache.

func (*RedisCache) BitCount added in v1.0.7

func (r *RedisCache) BitCount(key string, bitCount *redis.BitCount) (int64, error)

func (*RedisCache) BitField added in v1.0.7

func (r *RedisCache) BitField(key string, args ...interface{}) ([]int64, error)

func (*RedisCache) BitOpAnd added in v1.0.7

func (r *RedisCache) BitOpAnd(destKey string, keys ...string) (int64, error)

func (*RedisCache) BitOpNot added in v1.0.7

func (r *RedisCache) BitOpNot(destKey string, key string) (int64, error)

func (*RedisCache) BitOpOr added in v1.0.7

func (r *RedisCache) BitOpOr(destKey string, keys ...string) (int64, error)

func (*RedisCache) BitOpXor added in v1.0.7

func (r *RedisCache) BitOpXor(destKey string, keys ...string) (int64, error)

func (*RedisCache) BitPos added in v1.0.7

func (r *RedisCache) BitPos(key string, bit int64, pos ...int64) (int64, error)

func (*RedisCache) Client added in v0.5.0

func (r *RedisCache) Client() interface{}

func (*RedisCache) Close added in v1.2.1

func (r *RedisCache) Close() error

func (*RedisCache) Decr

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

func (*RedisCache) Del added in v1.0.5

func (r *RedisCache) Del(keys ...string) (int64, error)

func (*RedisCache) Delete

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

func (*RedisCache) DeleteByPrefix

func (r *RedisCache) DeleteByPrefix(prefix string) error

DeleteByPrefix Delete deletes cached value by given prefix key.

func (*RedisCache) Exist added in v1.0.6

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

func (*RedisCache) Exists added in v1.0.5

func (r *RedisCache) Exists(keys ...string) (int64, error)

func (*RedisCache) Expire added in v1.0.5

func (r *RedisCache) Expire(key string, expiration time.Duration) (bool, error)

func (*RedisCache) Flush

func (r *RedisCache) Flush() error

func (*RedisCache) Get

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

func (*RedisCache) GetBit added in v1.0.7

func (r *RedisCache) GetBit(key string, offset int64) (int64, error)

func (*RedisCache) HDel added in v1.0.5

func (r *RedisCache) HDel(key string, fields ...string) (int64, error)

func (*RedisCache) HExists added in v1.0.5

func (r *RedisCache) HExists(key, field string) (bool, error)

func (*RedisCache) HGet added in v1.0.5

func (r *RedisCache) HGet(key, field string) (string, error)

func (*RedisCache) HGetAll added in v1.0.5

func (r *RedisCache) HGetAll(key string) (map[string]string, error)

func (*RedisCache) HMGet added in v1.0.5

func (r *RedisCache) HMGet(key string, fields ...string) ([]interface{}, error)

func (*RedisCache) HMSet added in v1.0.5

func (r *RedisCache) HMSet(key string, values ...interface{}) (bool, error)

func (*RedisCache) HSet added in v1.0.5

func (r *RedisCache) HSet(key string, values ...interface{}) (int64, error)

func (*RedisCache) HSetNX added in v1.0.5

func (r *RedisCache) HSetNX(key, field string, value interface{}) (bool, error)

func (*RedisCache) Incr

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

func (*RedisCache) Key added in v0.5.2

func (r *RedisCache) Key(key string) string

func (*RedisCache) LLen added in v1.0.5

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

func (*RedisCache) LPush added in v1.0.5

func (r *RedisCache) LPush(key string, values ...interface{}) (int64, error)

func (*RedisCache) LRange added in v1.0.5

func (r *RedisCache) LRange(key string, start, stop int64) ([]string, error)

func (*RedisCache) RPop added in v1.0.7

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

func (*RedisCache) RPopCount added in v1.0.7

func (r *RedisCache) RPopCount(key string, count int) ([]string, error)

func (*RedisCache) RPopLPush added in v1.0.7

func (r *RedisCache) RPopLPush(source, destination string) (string, error)

func (*RedisCache) RPush added in v1.0.7

func (r *RedisCache) RPush(key string, values ...interface{}) (int64, error)

func (*RedisCache) RPushX added in v1.0.7

func (r *RedisCache) RPushX(key string, values ...interface{}) (int64, error)

func (*RedisCache) RunScript added in v1.0.7

func (r *RedisCache) RunScript(src string, keys []string, args ...interface{}) (interface{}, error)

func (*RedisCache) SAdd added in v1.0.5

func (r *RedisCache) SAdd(key string, members ...interface{}) (int64, error)

func (*RedisCache) SCard added in v1.0.5

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

func (*RedisCache) SRem added in v1.0.5

func (r *RedisCache) SRem(key string, members ...interface{}) (int64, error)

func (*RedisCache) SScan added in v1.0.5

func (r *RedisCache) SScan(key string, cursor uint64, match string, count int64) (keys []string, cursorOut uint64, err error)

func (*RedisCache) Set

func (r *RedisCache) Set(key, val string, expiration time.Duration) error

func (*RedisCache) SetBit added in v1.0.7

func (r *RedisCache) SetBit(key string, offset int64, value int) (int64, error)

func (*RedisCache) SetEX added in v1.0.5

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

func (*RedisCache) SetNX added in v1.0.5

func (r *RedisCache) SetNX(key string, value interface{}, expiration time.Duration) (bool, error)

func (*RedisCache) TTL added in v1.0.5

func (r *RedisCache) TTL(key string) (time.Duration, error)

func (*RedisCache) Touch

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

func (*RedisCache) Type added in v1.0.5

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

func (*RedisCache) ZAdd added in v1.0.5

func (r *RedisCache) ZAdd(key string, members ...*redis.Z) (int64, error)

func (*RedisCache) ZRange added in v1.0.5

func (r *RedisCache) ZRange(key string, start, stop int64) ([]string, error)

func (*RedisCache) ZRank added in v1.0.5

func (r *RedisCache) ZRank(key, member string) (int64, error)

func (*RedisCache) ZRem added in v1.0.5

func (r *RedisCache) ZRem(key string, members ...interface{}) (int64, error)

func (*RedisCache) ZScore added in v1.0.5

func (r *RedisCache) ZScore(key, member string) (float64, error)

type Store

type Store interface {
	Client() interface{}
	Close() error

	Key(key string) string

	Set(key, val string, expiration time.Duration) error
	Get(key string) (string, error)

	HGet(key, field string) (string, error)
	HGetAll(key string) (map[string]string, error)
	HSet(key string, values ...interface{}) (int64, error)
	HExists(key, field string) (bool, error)

	HMGet(key string, fields ...string) ([]interface{}, error)
	HMSet(key string, values ...interface{}) (bool, error)

	SCard(key string) (int64, error)
	SAdd(key string, members ...interface{}) (int64, error)
	SRem(key string, members ...interface{}) (int64, error)

	LRange(key string, start, stop int64) ([]string, error)
	LPush(key string, values ...interface{}) (int64, error)
	LLen(key string) (int64, error)
	RPop(key string) (string, error)
	RPopCount(key string, count int) ([]string, error)
	RPopLPush(source, destination string) (string, error)
	RPush(key string, values ...interface{}) (int64, error)
	RPushX(key string, values ...interface{}) (int64, error)

	ZAdd(key string, members ...*redis.Z) (int64, error)
	ZRange(key string, start, stop int64) ([]string, error)
	ZRank(key, member string) (int64, error)
	ZScore(key, member string) (float64, error)
	ZRem(key string, members ...interface{}) (int64, error)

	SetEX(key string, value interface{}, expiration time.Duration) (string, error)
	SetNX(key string, value interface{}, expiration time.Duration) (bool, error)
	HSetNX(key, field string, value interface{}) (bool, error)
	SScan(key string, cursor uint64, match string, count int64) ([]string, uint64, error)
	RunScript(src string, keys []string, args ...interface{}) (interface{}, error)

	GetBit(key string, offset int64) (int64, error)
	SetBit(key string, offset int64, value int) (int64, error)
	BitCount(key string, bitCount *redis.BitCount) (int64, error)
	BitOpAnd(destKey string, keys ...string) (int64, error)
	BitOpOr(destKey string, keys ...string) (int64, error)
	BitOpXor(destKey string, keys ...string) (int64, error)
	BitOpNot(destKey string, key string) (int64, error)
	BitPos(key string, bit int64, pos ...int64) (int64, error)
	BitField(key string, args ...interface{}) ([]int64, error)

	Del(keys ...string) (int64, error)
	Delete(key string) error
	DeleteByPrefix(prefix string) error
	HDel(key string, fields ...string) (int64, error)

	Incr(key string) (int64, error)
	Decr(key string) (int64, error)

	Type(key string) (string, error)
	TTL(key string) (time.Duration, error)
	Expire(key string, expiration time.Duration) (bool, error)
	Exists(keys ...string) (int64, error)

	Exist(key string) bool
	Touch(key string) error
	Flush() error
	// contains filtered or unexported methods
}

Store Cache is the interface that operates the cache data.

Jump to

Keyboard shortcuts

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