Import path:
gitlab.soludian.com/soludian/fountain/libs/cache/arc_cache
arc_cache
go
import "gitlab.soludian.com/soludian/fountain/libs/cache/arc_cache"Index
- Constants
- func NewARCCache() cache.Cache
- type Cache
- func (ac *Cache) ClearAll(ctx context.Context) error
- func (rc *Cache) Close() error
- func (ac *Cache) Decr(key string) (int64, error)
- func (ac *Cache) Delete(key string) error
- func (rc *Cache) Get(key string) ([]byte, error)
- func (rc *Cache) GetDefaultConfig() string
- func (rc *Cache) GetMulti(keys []string) ([][]byte, error)
- func (ac *Cache) Has(key string) bool
- func (ac *Cache) Incr(key string) (int64, error)
- func (ac *Cache) Peek(key string) (any, error)
- func (ac *Cache) PeekMulti(keys []string) ([]any, error)
- func (ac *Cache) Put(key string, val any, ttl time.Duration) error
- func (ac *Cache) PutMulti(values map[string]any, ttl time.Duration) error
- func (rc *Cache) Reset() error
- func (rc *Cache) Set(key string, val []byte, ttl time.Duration) error
- func (rc *Cache) SetMulti(values map[string][]byte, ttl time.Duration) error
- func (ac *Cache) SetName(name string)
- func (ac *Cache) StartAndGC(configs ...string) error
Constants
go
const (
KPackageName = "arc_cache"
DefaultCapacity = 10 * 1024
)go
const DefaultConfig = `{"capacity": 1024}`func NewARCCache
go
func NewARCCache() cache.Cachetype Cache
Constantly balances between LRU and LFU, to improve the combined result.
go
type Cache struct {
// contains filtered or unexported fields
}func (*Cache) ClearAll
go
func (ac *Cache) ClearAll(ctx context.Context) errorClear all cache.
func (*Cache) Close
go
func (rc *Cache) Close() errorClose the database
func (*Cache) Decr
go
func (ac *Cache) Decr(key string) (int64, error)Decrement a cached int value by key, as a counter.
func (*Cache) Delete
go
func (ac *Cache) Delete(key string) errorDelete cached value by key. Should not return error if key not found
func (*Cache) Get
go
func (rc *Cache) Get(key string) ([]byte, error)Get gets a key's value from memcache.
func (*Cache) GetDefaultConfig
go
func (rc *Cache) GetDefaultConfig() stringfunc (*Cache) GetMulti
go
func (rc *Cache) GetMulti(keys []string) ([][]byte, error)GetMulti gets one or keys values from ssdb.
func (*Cache) Has
go
func (ac *Cache) Has(key string) boolCheck cache existed by key.
func (*Cache) Incr
go
func (ac *Cache) Incr(key string) (int64, error)Increment a cached int value by key, as a counter.
func (*Cache) Peek
go
func (ac *Cache) Peek(key string) (any, error)Peek a cached value by key.
func (*Cache) PeekMulti
go
func (ac *Cache) PeekMulti(keys []string) ([]any, error)PeekMulti is a batch version of Get.
func (*Cache) Put
go
func (ac *Cache) Put(key string, val any, ttl time.Duration) errorSet a cached value with key and expire time.
func (*Cache) PutMulti
go
func (ac *Cache) PutMulti(values map[string]any, ttl time.Duration) errorSet a cached values with key and expire time
func (*Cache) Reset
go
func (rc *Cache) Reset() errorfunc (*Cache) Set
go
func (rc *Cache) Set(key string, val []byte, ttl time.Duration) errorfunc (*Cache) SetMulti
go
func (rc *Cache) SetMulti(values map[string][]byte, ttl time.Duration) errorfunc (*Cache) SetName
go
func (ac *Cache) SetName(name string)func (*Cache) StartAndGC
go
func (ac *Cache) StartAndGC(configs ...string) errorStart gc routine based on config string settings. config: must be in the format {"capacity": 1024}
Generated by gomarkdoc