Documentation ¶
Index ¶
- Constants
- func NotFoundWithCause(e error) error
- type BigcacheClientInterface
- type BigcacheStore
- func (s *BigcacheStore) Clear(_ context.Context) error
- func (s *BigcacheStore) Delete(_ context.Context, key any) error
- func (s *BigcacheStore) Get(_ context.Context, key any) (any, error)
- func (s *BigcacheStore) GetType() string
- func (s *BigcacheStore) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error)
- func (s *BigcacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (s *BigcacheStore) Set(ctx context.Context, key any, value any, options ...Option) error
- type FreecacheClientInterface
- type FreecacheStore
- func (f *FreecacheStore) Clear(_ context.Context) error
- func (f *FreecacheStore) Delete(_ context.Context, key any) error
- func (f *FreecacheStore) Get(_ context.Context, key any) (any, error)
- func (f *FreecacheStore) GetType() string
- func (f *FreecacheStore) GetWithTTL(_ context.Context, key any) (any, time.Duration, error)
- func (f *FreecacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (f *FreecacheStore) Set(ctx context.Context, key any, value any, options ...Option) error
- type GoCacheClientInterface
- type GoCacheStore
- func (s *GoCacheStore) Clear(_ context.Context) error
- func (s *GoCacheStore) Delete(_ context.Context, key any) error
- func (s *GoCacheStore) Get(_ context.Context, key any) (any, error)
- func (s *GoCacheStore) GetType() string
- func (s *GoCacheStore) GetWithTTL(_ context.Context, key any) (any, time.Duration, error)
- func (s *GoCacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (s *GoCacheStore) Set(ctx context.Context, key any, value any, options ...Option) error
- type InvalidateOption
- type InvalidateOptionsMatcher
- type MemcacheClientInterface
- type MemcacheStore
- func (s *MemcacheStore) Clear(_ context.Context) error
- func (s *MemcacheStore) Delete(_ context.Context, key any) error
- func (s *MemcacheStore) Get(_ context.Context, key any) (any, error)
- func (s *MemcacheStore) GetType() string
- func (s *MemcacheStore) GetWithTTL(_ context.Context, key any) (any, time.Duration, error)
- func (s *MemcacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (s *MemcacheStore) Set(ctx context.Context, key any, value any, options ...Option) error
- type NotFound
- type Option
- type Options
- type OptionsMatcher
- type OptionsPegasus
- type PegasusStore
- func (p *PegasusStore) Clear(ctx context.Context) error
- func (p *PegasusStore) Close() error
- func (p *PegasusStore) Delete(ctx context.Context, key any) error
- func (p *PegasusStore) Get(ctx context.Context, key any) (any, error)
- func (p *PegasusStore) GetType() string
- func (p *PegasusStore) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error)
- func (p *PegasusStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (p *PegasusStore) Set(ctx context.Context, key, value any, options ...Option) error
- type RedisClientInterface
- type RedisClusterClientInterface
- type RedisClusterStore
- func (s *RedisClusterStore) Clear(ctx context.Context) error
- func (s *RedisClusterStore) Delete(ctx context.Context, key any) error
- func (s *RedisClusterStore) Get(ctx context.Context, key any) (any, error)
- func (s *RedisClusterStore) GetType() string
- func (s *RedisClusterStore) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error)
- func (s *RedisClusterStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (s *RedisClusterStore) Set(ctx context.Context, key any, value any, options ...Option) error
- type RedisStore
- func (s *RedisStore) Clear(ctx context.Context) error
- func (s *RedisStore) Delete(ctx context.Context, key any) error
- func (s *RedisStore) Get(ctx context.Context, key any) (any, error)
- func (s *RedisStore) GetType() string
- func (s *RedisStore) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error)
- func (s *RedisStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (s *RedisStore) Set(ctx context.Context, key any, value any, options ...Option) error
- type RistrettoClientInterface
- type RistrettoStore
- func (s *RistrettoStore) Clear(_ context.Context) error
- func (s *RistrettoStore) Delete(_ context.Context, key any) error
- func (s *RistrettoStore) Get(_ context.Context, key any) (any, error)
- func (s *RistrettoStore) GetType() string
- func (s *RistrettoStore) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error)
- func (s *RistrettoStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
- func (s *RistrettoStore) Set(ctx context.Context, key any, value any, options ...Option) error
- type StoreInterface
Constants ¶
const ( // BigcacheType represents the storage type as a string value BigcacheType = "bigcache" // BigcacheTagPattern represents the tag pattern to be used as a key in specified storage BigcacheTagPattern = "gocache_tag_%s" )
const ( // FreecacheType represents the storage type as a string value FreecacheType = "freecache" // FreecacheTagPattern represents the tag pattern to be used as a key in specified storage FreecacheTagPattern = "freecache_tag_%s" )
const ( // GoCacheType represents the storage type as a string value GoCacheType = "go-cache" // GoCacheTagPattern represents the tag pattern to be used as a key in specified storage GoCacheTagPattern = "gocache_tag_%s" )
const ( // MemcacheType represents the storage type as a string value MemcacheType = "memcache" // MemcacheTagPattern represents the tag pattern to be used as a key in specified storage MemcacheTagPattern = "gocache_tag_%s" TagKeyExpiry = 720 * time.Hour )
const ( // PegasusType represents the storage type as a string value PegasusType = "pegasus" // PegasusTagPattern represents the tag pattern to be used as a key in specified storage PegasusTagPattern = "gocache_tag_%s" // Pegasus ttl(time-to-live) in seconds: -1 if ttl is not set; -2 if entry doesn't exist PegasusNOTTL = -1 PegasusNOENTRY = -2 DefaultTable = "gocache_pegasus" DefaultTablePartitionNum = 4 DefaultScanNum = 100 )
const ( // RedisType represents the storage type as a string value RedisType = "redis" // RedisTagPattern represents the tag pattern to be used as a key in specified storage RedisTagPattern = "gocache_tag_%s" )
const ( // RedisType represents the storage type as a string value RedisClusterType = "rediscluster" // RedisTagPattern represents the tag pattern to be used as a key in specified storage RedisClusterTagPattern = "gocache_tag_%s" )
const ( // RistrettoType represents the storage type as a string value RistrettoType = "ristretto" // RistrettoTagPattern represents the tag pattern to be used as a key in specified storage RistrettoTagPattern = "gocache_tag_%s" )
const NOT_FOUND_ERR string = "value not found in store"
Variables ¶
This section is empty.
Functions ¶
func NotFoundWithCause ¶ added in v3.1.0
Types ¶
type BigcacheClientInterface ¶
type BigcacheClientInterface interface { Get(key string) ([]byte, error) Set(key string, entry []byte) error Delete(key string) error Reset() error }
BigcacheClientInterface represents a allegro/bigcache client
type BigcacheStore ¶
type BigcacheStore struct {
// contains filtered or unexported fields
}
BigcacheStore is a store for Bigcache
func NewBigcache ¶
func NewBigcache(client BigcacheClientInterface, options ...Option) *BigcacheStore
NewBigcache creates a new store to Bigcache instance(s)
func (*BigcacheStore) Clear ¶
func (s *BigcacheStore) Clear(_ context.Context) error
Clear resets all data in the store
func (*BigcacheStore) Delete ¶
func (s *BigcacheStore) Delete(_ context.Context, key any) error
Delete removes data from Bigcache for given key identifier
func (*BigcacheStore) GetType ¶
func (s *BigcacheStore) GetType() string
GetType returns the store type
func (*BigcacheStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*BigcacheStore) Invalidate ¶
func (s *BigcacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in Bigcache for given options
type FreecacheClientInterface ¶
type FreecacheClientInterface interface { Get(key []byte) (value []byte, err error) GetInt(key int64) (value []byte, err error) TTL(key []byte) (timeLeft uint32, err error) Set(key, value []byte, expireSeconds int) (err error) SetInt(key int64, value []byte, expireSeconds int) (err error) Del(key []byte) (affected bool) DelInt(key int64) (affected bool) Clear() }
FreecacheClientInterface represents a coocood/freecache client
type FreecacheStore ¶
type FreecacheStore struct {
// contains filtered or unexported fields
}
FreecacheStore is a store for freecache
func NewFreecache ¶
func NewFreecache(client FreecacheClientInterface, options ...Option) *FreecacheStore
NewFreecache creates a new store to freecache instance(s)
func (*FreecacheStore) Clear ¶
func (f *FreecacheStore) Clear(_ context.Context) error
Clear resets all data in the store
func (*FreecacheStore) Delete ¶
func (f *FreecacheStore) Delete(_ context.Context, key any) error
Delete deletes an item in the cache by key and returns err or nil if a delete occurred
func (*FreecacheStore) Get ¶
Get returns data stored from a given key. It returns the value or not found error
func (*FreecacheStore) GetType ¶
func (f *FreecacheStore) GetType() string
GetType returns the store type
func (*FreecacheStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*FreecacheStore) Invalidate ¶
func (f *FreecacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in freecache for given options
func (*FreecacheStore) Set ¶
Set sets a key, value and expiration for a cache entry and stores it in the cache. If the key is larger than 65535 or value is larger than 1/1024 of the cache size, the entry will not be written to the cache. expireSeconds <= 0 means no expire, but it can be evicted when cache is full.
type GoCacheClientInterface ¶
type GoCacheClientInterface interface { Get(k string) (any, bool) GetWithExpiration(k string) (any, time.Time, bool) Set(k string, x any, d time.Duration) Delete(k string) Flush() }
GoCacheClientInterface represents a github.com/patrickmn/go-cache client
type GoCacheStore ¶
type GoCacheStore struct {
// contains filtered or unexported fields
}
GoCacheStore is a store for GoCache (memory) library
func NewGoCache ¶
func NewGoCache(client GoCacheClientInterface, options ...Option) *GoCacheStore
NewGoCache creates a new store to GoCache (memory) library instance
func (*GoCacheStore) Clear ¶
func (s *GoCacheStore) Clear(_ context.Context) error
Clear resets all data in the store
func (*GoCacheStore) Delete ¶
func (s *GoCacheStore) Delete(_ context.Context, key any) error
Delete removes data in GoCache memoey cache for given key identifier
func (*GoCacheStore) GetType ¶
func (s *GoCacheStore) GetType() string
GetType returns the store type
func (*GoCacheStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*GoCacheStore) Invalidate ¶
func (s *GoCacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in GoCache memoey cache for given options
type InvalidateOption ¶
type InvalidateOption func(o *invalidateOptions)
InvalidateOption represents a cache invalidation function.
func WithInvalidateTags ¶
func WithInvalidateTags(tags []string) InvalidateOption
WithInvalidateTags allows setting the invalidate tags.
type InvalidateOptionsMatcher ¶
type InvalidateOptionsMatcher struct {
Tags []string
}
func (InvalidateOptionsMatcher) Matches ¶
func (m InvalidateOptionsMatcher) Matches(x interface{}) bool
func (InvalidateOptionsMatcher) String ¶
func (m InvalidateOptionsMatcher) String() string
type MemcacheClientInterface ¶
type MemcacheClientInterface interface { Get(key string) (item *memcache.Item, err error) Set(item *memcache.Item) error Delete(item string) error FlushAll() error CompareAndSwap(item *memcache.Item) error Add(item *memcache.Item) error }
MemcacheClientInterface represents a bradfitz/gomemcache client
type MemcacheStore ¶
type MemcacheStore struct {
// contains filtered or unexported fields
}
MemcacheStore is a store for Memcache
func NewMemcache ¶
func NewMemcache(client MemcacheClientInterface, options ...Option) *MemcacheStore
NewMemcache creates a new store to Memcache instance(s)
func (*MemcacheStore) Clear ¶
func (s *MemcacheStore) Clear(_ context.Context) error
Clear resets all data in the store
func (*MemcacheStore) Delete ¶
func (s *MemcacheStore) Delete(_ context.Context, key any) error
Delete removes data from Memcache for given key identifier
func (*MemcacheStore) GetType ¶
func (s *MemcacheStore) GetType() string
GetType returns the store type
func (*MemcacheStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*MemcacheStore) Invalidate ¶
func (s *MemcacheStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in Memcache for given options
type Option ¶
type Option func(o *Options)
Option represents a store option function.
func WithCost ¶
WithCost allows setting the memory capacity used by the item when setting a value. Actually it seems to be used by Ristretto library only.
func WithExpiration ¶
WithExpiration allows to specify an expiration time when setting a value.
type OptionsMatcher ¶
func (OptionsMatcher) Matches ¶
func (m OptionsMatcher) Matches(x interface{}) bool
func (OptionsMatcher) String ¶
func (m OptionsMatcher) String() string
type OptionsPegasus ¶
type OptionsPegasus struct { *Options MetaServers []string TableName string TablePartitionNum int TableScanNum int }
OptionsPegasus is options of Pegasus
type PegasusStore ¶
type PegasusStore struct {
// contains filtered or unexported fields
}
PegasusStore is a store for Pegasus
func NewPegasus ¶
func NewPegasus(ctx context.Context, options *OptionsPegasus) (*PegasusStore, error)
NewPegasus creates a new store to pegasus instance(s)
func (*PegasusStore) Clear ¶
func (p *PegasusStore) Clear(ctx context.Context) error
Clear resets all data in the store
func (*PegasusStore) Delete ¶
func (p *PegasusStore) Delete(ctx context.Context, key any) error
Delete removes data from Pegasus for given key identifier
func (*PegasusStore) GetType ¶
func (p *PegasusStore) GetType() string
GetType returns the store type
func (*PegasusStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*PegasusStore) Invalidate ¶
func (p *PegasusStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in Pegasus for given options
type RedisClientInterface ¶
type RedisClientInterface interface { Get(ctx context.Context, key string) *redis.StringCmd TTL(ctx context.Context, key string) *redis.DurationCmd Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd Set(ctx context.Context, key string, values any, expiration time.Duration) *redis.StatusCmd Del(ctx context.Context, keys ...string) *redis.IntCmd FlushAll(ctx context.Context) *redis.StatusCmd SAdd(ctx context.Context, key string, members ...any) *redis.IntCmd SMembers(ctx context.Context, key string) *redis.StringSliceCmd }
RedisClientInterface represents a go-redis/redis client
type RedisClusterClientInterface ¶
type RedisClusterClientInterface interface { Get(ctx context.Context, key string) *redis.StringCmd TTL(ctx context.Context, key string) *redis.DurationCmd Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd Set(ctx context.Context, key string, values any, expiration time.Duration) *redis.StatusCmd Del(ctx context.Context, keys ...string) *redis.IntCmd FlushAll(ctx context.Context) *redis.StatusCmd SAdd(ctx context.Context, key string, members ...any) *redis.IntCmd SMembers(ctx context.Context, key string) *redis.StringSliceCmd }
RedisClusterClientInterface represents a go-redis/redis clusclient
type RedisClusterStore ¶
type RedisClusterStore struct {
// contains filtered or unexported fields
}
RedisStore is a store for Redis
func NewRedisCluster ¶
func NewRedisCluster(client RedisClusterClientInterface, options ...Option) *RedisClusterStore
NewRedis creates a new store to Redis instance(s)
func (*RedisClusterStore) Clear ¶
func (s *RedisClusterStore) Clear(ctx context.Context) error
Clear resets all data in the store
func (*RedisClusterStore) Delete ¶
func (s *RedisClusterStore) Delete(ctx context.Context, key any) error
Delete removes data from Redis for given key identifier
func (*RedisClusterStore) GetType ¶
func (s *RedisClusterStore) GetType() string
GetType returns the store type
func (*RedisClusterStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*RedisClusterStore) Invalidate ¶
func (s *RedisClusterStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in Redis for given options
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore is a store for Redis
func NewRedis ¶
func NewRedis(client RedisClientInterface, options ...Option) *RedisStore
NewRedis creates a new store to Redis instance(s)
func (*RedisStore) Clear ¶
func (s *RedisStore) Clear(ctx context.Context) error
Clear resets all data in the store
func (*RedisStore) Delete ¶
func (s *RedisStore) Delete(ctx context.Context, key any) error
Delete removes data from Redis for given key identifier
func (*RedisStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*RedisStore) Invalidate ¶
func (s *RedisStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in Redis for given options
type RistrettoClientInterface ¶
type RistrettoClientInterface interface { Get(key any) (any, bool) SetWithTTL(key, value any, cost int64, ttl time.Duration) bool Del(key any) Clear() }
RistrettoClientInterface represents a dgraph-io/ristretto client
type RistrettoStore ¶
type RistrettoStore struct {
// contains filtered or unexported fields
}
RistrettoStore is a store for Ristretto (memory) library
func NewRistretto ¶
func NewRistretto(client RistrettoClientInterface, options ...Option) *RistrettoStore
NewRistretto creates a new store to Ristretto (memory) library instance
func (*RistrettoStore) Clear ¶
func (s *RistrettoStore) Clear(_ context.Context) error
Clear resets all data in the store
func (*RistrettoStore) Delete ¶
func (s *RistrettoStore) Delete(_ context.Context, key any) error
Delete removes data in Ristretto memoey cache for given key identifier
func (*RistrettoStore) GetType ¶
func (s *RistrettoStore) GetType() string
GetType returns the store type
func (*RistrettoStore) GetWithTTL ¶
GetWithTTL returns data stored from a given key and its corresponding TTL
func (*RistrettoStore) Invalidate ¶
func (s *RistrettoStore) Invalidate(ctx context.Context, options ...InvalidateOption) error
Invalidate invalidates some cache data in Redis for given options
type StoreInterface ¶
type StoreInterface interface { Get(ctx context.Context, key any) (any, error) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error) Set(ctx context.Context, key any, value any, options ...Option) error Delete(ctx context.Context, key any) error Invalidate(ctx context.Context, options ...InvalidateOption) error Clear(ctx context.Context) error GetType() string }
StoreInterface is the interface for all available stores