Documentation ¶
Index ¶
- Variables
- type Cache
- func (c *Cache) BRPopLPush(source string, destination string, timeout time.Duration) string
- func (c *Cache) Decrement(k string, n int64) (int64, error)
- func (c *Cache) Delete(k ...string) int64
- func (c *Cache) DeleteExpired()
- func (c *Cache) Exists(s ...string) int64
- func (c *Cache) Flush()
- func (c *Cache) Get(k string) interface{}
- func (c *Cache) GetLock(s string, duration time.Duration, duration2 time.Duration) (string, error)
- func (c *Cache) GetString(k string) (string, error)
- func (c *Cache) HashAll(key string) map[string]string
- func (c *Cache) HashDel(key string, values ...string) int64
- func (c *Cache) HashExist(key, values string) bool
- func (c *Cache) HashGet(key, value string) string
- func (c *Cache) HashGets(key string, value ...string) []interface{}
- func (c *Cache) HashKeys(key string) []string
- func (c *Cache) HashLen(key string) int64
- func (c *Cache) HashSet(key string, values ...interface{}) int64
- func (c *Cache) Increment(k string, n int64) (int64, error)
- func (c *Cache) IncrementFloat(k string, n float64) (float64, error)
- func (c *Cache) IsExist(k string) bool
- func (c *Cache) LPush(s string, values ...interface{}) int64
- func (c *Cache) LRange(key string, start int64, stop int64) []string
- func (c *Cache) LRem(key string, count int64, value interface{}) int64
- func (c *Cache) Load(r io.Reader) error
- func (c *Cache) LoadFile(fname string) error
- func (c *Cache) Pipeline() redis.Pipeliner
- func (c *Cache) RPop(s string) string
- func (c *Cache) RPopLPush(source string, destination string) string
- func (c *Cache) ReleaseLock(s string, s2 string) bool
- func (c *Cache) Save(w io.Writer) (err error)
- func (c *Cache) SaveFile(fname string) error
- func (c *Cache) Scan(cursor uint64, match string, count int64) ([]string, uint64)
- func (c *Cache) Set(key string, value interface{}, timeout time.Duration) error
- func (c *Cache) SetEX(key string, val interface{}, timeout time.Duration) error
- func (c *Cache) SetNX(key string, value interface{}, expiration time.Duration) bool
- func (c *Cache) WithContext(ctx context.Context) icache.ICache
- func (c *Cache) WithDB(db int) icache.ICache
- func (c *Cache) XAck(key string, group string, ids ...string) int64
- func (c *Cache) XAdd(key, msgId string, trim bool, maxLength int64, value interface{}) string
- func (c *Cache) XAddKey(key, msgId string, trim bool, maxLength int64, vKey string, value interface{}) string
- func (c *Cache) XClaim(key string, group string, consumer string, id string, msIdle int64) []redis.XMessage
- func (c *Cache) XDel(key string, id ...string) int64
- func (c *Cache) XGroupCreateMkStream(key string, group string, start string) string
- func (c *Cache) XGroupDelConsumer(key string, group string, consumer string) int64
- func (c *Cache) XGroupDestroy(key string, group string) int64
- func (c *Cache) XGroupSetID(key string, group string, start string) string
- func (c *Cache) XInfoConsumers(key string, group string) []redis.XInfoConsumer
- func (c *Cache) XInfoGroups(s string) []redis.XInfoGroup
- func (c *Cache) XInfoStream(key string) *redis.XInfoStream
- func (c *Cache) XLen(s string) int64
- func (c *Cache) XPending(key string, group string) *redis.XPending
- func (c *Cache) XPendingExt(key string, group string, startId string, endId string, count int64, ...) []redis.XPendingExt
- func (c *Cache) XRange(key string, start string, stop string) []redis.XMessage
- func (c *Cache) XRangeN(key string, start string, stop string, count int64) []redis.XMessage
- func (c *Cache) XRead(key string, startId string, count int64, block int64) []redis.XMessage
- func (c *Cache) XReadGroup(key string, group string, consumer string, count int64, block int64, ...) []redis.XMessage
- func (c *Cache) XTrimMaxLen(key string, maxLen int64) int64
- func (c *Cache) ZAdd(s string, f float64, i ...interface{}) int64
- func (c *Cache) ZRangeByScore(s string, i int64, i2 int64, i3 int64, i4 int64) []string
- func (c *Cache) ZRem(s string, i ...interface{}) int64
- type Option
- type ShardedCache
- func (sc *ShardedCache) Decrement(key string, val int64) (int64, error)
- func (sc *ShardedCache) Delete(key string) (int64, error)
- func (sc *ShardedCache) DeleteExpired()
- func (sc *ShardedCache) Flush()
- func (sc *ShardedCache) Get(key string) interface{}
- func (sc *ShardedCache) GetString(key string) (string, error)
- func (sc *ShardedCache) Increment(key string, val int64) (int64, error)
- func (sc *ShardedCache) IncrementFloat(key string, val float64) (float64, error)
- func (sc *ShardedCache) IsExist(key string) bool
- func (sc *ShardedCache) Set(key string, val interface{}, timeout time.Duration) error
- func (sc *ShardedCache) WithContext(ctx context.Context) icache.ICache
- func (sc *ShardedCache) WithDB(db int) icache.ICache
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyExists = fmt.Errorf("item already exists") ErrCacheMiss = fmt.Errorf("item not found") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
func New ¶
Return a new cache with a given default expiration duration and cleanup interval. If the expiration duration is less than 1, the items in the cache never expire (by default), and must be deleted manually. If the cleanup interval is less than one, expired items are not deleted from the cache before their next lookup or before calling DeleteExpired.
func (*Cache) BRPopLPush ¶ added in v0.3.1
func (*Cache) Decrement ¶
Decrement an item of type int, int8, int16, int32, int64, uintptr, uint, uint8, uint32, or int64 by n. Returns an error if the item's value is not an integer, if it was not found, or if it is not possible to decrement it by n. Stops at 0 on underflow.
func (*Cache) DeleteExpired ¶
func (c *Cache) DeleteExpired()
Delete all expired items from the cache.
func (*Cache) Get ¶
Get an item from the cache. Returns the item or nil, and a bool indicating whether the key was found.
func (*Cache) GetString ¶
Get an item from the cache. Returns the item or nil, and a bool indicating whether the key was found.
func (*Cache) Increment ¶
Increment an item of type int, int8, int16, int32, int64, uintptr, uint, uint8, uint32, or int64 by n. Returns an error if the item's value is not an integer, if it was not found, or if it is not possible to increment it by n. Wraps around on overlow.
func (*Cache) IncrementFloat ¶
Increment an item of type float32 or float64 by n. Returns an error if the item's value is not floating point, if it was not found, or if it is not possible to increment it by n. Pass a negative number to decrement the value.
func (*Cache) Load ¶
Add (Gob-serialized) cache items from an io.Reader, excluding any items with keys that already exist in the current cache.
func (*Cache) LoadFile ¶
Load and add cache items from the given filename, excluding any items with keys that already exist in the current cache.
func (*Cache) SaveFile ¶
Save the cache's items to the given filename, creating the file if it doesn't exist, and overwriting it if it does.
func (*Cache) Set ¶
Add an item to the cache, replacing any existing item. If the duration is 0, the cache's default expiration time is used. If it is -1, the item never expires.
func (*Cache) XGroupCreateMkStream ¶ added in v0.2.15
func (*Cache) XGroupDelConsumer ¶ added in v0.2.15
func (*Cache) XGroupDestroy ¶ added in v0.2.15
func (*Cache) XGroupSetID ¶ added in v0.2.15
func (*Cache) XInfoConsumers ¶ added in v0.2.15
func (*Cache) XInfoGroups ¶ added in v0.2.15
func (*Cache) XInfoStream ¶ added in v0.2.15
func (*Cache) XPendingExt ¶ added in v0.2.15
func (*Cache) XReadGroup ¶ added in v0.2.15
func (*Cache) XTrimMaxLen ¶ added in v0.2.15
func (*Cache) ZRangeByScore ¶ added in v0.2.12
type Option ¶
type Option func(p *config)
func WithAttributes ¶
WithAttributes specifies additional attributes to be added to the span.
func WithCleanupInterval ¶
func WithDefaultExpiration ¶
func WithTracer ¶
WithTracer specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.
type ShardedCache ¶
type ShardedCache struct {
// contains filtered or unexported fields
}
func (*ShardedCache) Decrement ¶
func (sc *ShardedCache) Decrement(key string, val int64) (int64, error)
func (*ShardedCache) DeleteExpired ¶
func (sc *ShardedCache) DeleteExpired()
func (*ShardedCache) Flush ¶
func (sc *ShardedCache) Flush()
func (*ShardedCache) Get ¶
func (sc *ShardedCache) Get(key string) interface{}
func (*ShardedCache) Increment ¶
func (sc *ShardedCache) Increment(key string, val int64) (int64, error)
func (*ShardedCache) IncrementFloat ¶
func (sc *ShardedCache) IncrementFloat(key string, val float64) (float64, error)
func (*ShardedCache) IsExist ¶
func (sc *ShardedCache) IsExist(key string) bool
func (*ShardedCache) Set ¶
func (sc *ShardedCache) Set(key string, val interface{}, timeout time.Duration) error
func (*ShardedCache) WithContext ¶
func (sc *ShardedCache) WithContext(ctx context.Context) icache.ICache