cache

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 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

	// Maximum number of socket connections.
	// Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
	PoolSize int
	// Minimum number of idle connections which is useful when establishing
	// new connection is slow.
	MinIdleConns 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) 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) RPop added in v1.3.0

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

func (*Cache) RPopCount added in v1.3.0

func (this *Cache) RPopCount(key string, count int) ([]string, error)

func (*Cache) RPopLPush added in v1.3.0

func (this *Cache) RPopLPush(source, destination string) (string, error)

func (*Cache) RPush added in v1.3.0

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

func (*Cache) RPushX added in v1.3.0

func (this *Cache) RPushX(key string, values ...interface{}) (int64, 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) Set

func (this *Cache) Set(key, val string, expiration time.Duration) 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)

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) 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) 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) 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) 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) Set

func (c *MemoryCache) Set(key, val string, expiration time.Duration) 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)

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) 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) 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) 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) 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) Set

func (r *RedisCache) Set(key, val string, expiration time.Duration) 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)

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)

	HMSet(key string, values ...interface{}) (bool, error)
	HMGet(key string, fields ...string) ([]interface{}, 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)

	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