Versions in this module Expand all Collapse all v1 v1.0.2 Mar 14, 2024 v1.0.1 Mar 14, 2024 Changes in this version + const MinUint32 + const MinUint64 + var CreateFileCacheDirFailed = berror.DefineCode(4002009, moduleName, "CreateFileCacheDirFailed", ...) + var DecrementOverflow = berror.DefineCode(4002005, moduleName, "DecrementOverflow", ...) + var DefaultEvery = 60 + var DeleteFailed = berror.DefineCode(5002008, moduleName, "DeleteFailed", ...) + var DeleteFileCacheItemFailed = berror.DefineCode(5002001, moduleName, "DeleteFileCacheItemFailed", ...) + var DialFailed = berror.DefineCode(5002005, moduleName, "DialFailed", ...) + var DuplicateAdapter = berror.DefineCode(4002002, moduleName, "DuplicateAdapter", ...) + var ErrDecrementOverflow = berror.Error(DecrementOverflow, "this decr invocation will overflow.") + var ErrIncrementOverflow = berror.Error(IncrementOverflow, "this incr invocation will overflow.") + var ErrKeyExpired = berror.Error(KeyExpired, "the key is expired") + var ErrKeyNotExist = berror.Error(KeyNotExist, "the key isn't exist") + var ErrNotIntegerType = berror.Error(NotIntegerType, "item val is not (u)int (u)int32 (u)int64") + var FileCacheDirectoryLevel = 2 + var FileCacheEmbedExpiry time.Duration + var FileCacheFileSuffix = ".bin" + var FileCachePath = "cache" + var GobEncodeDataFailed = berror.DefineCode(4002013, moduleName, "GobEncodeDataFailed", ...) + var IncrementOverflow = berror.DefineCode(4002004, moduleName, "IncrementOverflow", ...) + var InvalidConnection = berror.DefineCode(5002004, moduleName, "InvalidConnection", ...) + var InvalidFileCacheDirectoryLevelCfg = berror.DefineCode(4002007, moduleName, "InvalidFileCacheDirectoryLevelCfg", ...) + var InvalidFileCacheEmbedExpiryCfg = berror.DefineCode(4002008, moduleName, "InvalidFileCacheEmbedExpiryCfg", ...) + var InvalidFileCachePath = berror.DefineCode(4002010, moduleName, "InvalidFilePath", ...) + var InvalidGobEncodedData = berror.DefineCode(4002012, moduleName, "InvalidEncodedData", ...) + var InvalidInitParameters = berror.DefineCode(4002025, moduleName, "InvalidInitParameters", ...) + var InvalidLoadFunc = berror.DefineCode(4002023, moduleName, "InvalidLoadFunc", ...) + var InvalidMemCacheCfg = berror.DefineCode(4002018, moduleName, "InvalidMemCacheCfg", ...) + var InvalidMemCacheValue = berror.DefineCode(4002019, moduleName, "InvalidMemCacheValue", ...) + var InvalidMemoryCacheCfg = berror.DefineCode(4002017, moduleName, "InvalidMemoryCacheCfg", ...) + var InvalidRedisCacheCfg = berror.DefineCode(4002020, moduleName, "InvalidRedisCacheCfg", ...) + var InvalidSsdbCacheCfg = berror.DefineCode(4002021, moduleName, "InvalidSsdbCacheCfg", ...) + var InvalidSsdbCacheValue = berror.DefineCode(4002022, moduleName, "InvalidSsdbCacheValue", ...) + var KeyExpired = berror.DefineCode(4002014, moduleName, "KeyExpired", ...) + var KeyNotExist = berror.DefineCode(4002015, moduleName, "KeyNotExist", ...) + var LoadFuncFailed = berror.DefineCode(4002024, moduleName, "LoadFuncFailed", ...) + var MemCacheCurdFailed = berror.DefineCode(5002002, moduleName, "MemCacheError", ...) + var MultiGetFailed = berror.DefineCode(4002016, moduleName, "MultiGetFailed", ...) + var NilCacheAdapter = berror.DefineCode(4002001, moduleName, "NilCacheAdapter", ...) + var NotIntegerType = berror.DefineCode(4002006, moduleName, "NotIntegerType", ...) + var PersistCacheFailed = berror.DefineCode(4002026, moduleName, "PersistCacheFailed", ...) + var ReadFileCacheContentFailed = berror.DefineCode(4002011, moduleName, "ReadFileCacheContentFailed", ...) + var RedisCacheCurdFailed = berror.DefineCode(5002003, moduleName, "RedisCacheCurdFailed", ...) + var SsdbBadResponse = berror.DefineCode(5002007, moduleName, "SsdbBadResponse", ...) + var SsdbCacheCurdFailed = berror.DefineCode(5002006, moduleName, "SsdbCacheCurdFailed", ...) + var UnknownAdapter = berror.DefineCode(4002003, moduleName, "UnknownAdapter", ...) + func FileGetContents(filename string) ([]byte, error) + func FilePutContents(filename string, content []byte) error + func GetBool(v interface{}) bool + func GetFloat64(v interface{}) float64 + func GetInt(v interface{}) int + func GetInt64(v interface{}) int64 + func GetString(v interface{}) string + func GobDecode(data []byte, to *FileCacheItem) error + func GobEncode(data interface{}) ([]byte, error) + func Register(name string, adapter Instance) + type BloomFilter interface + Add func(data string) + Test func(data string) bool + type BloomFilterCache struct + func NewBloomFilterCache(cache Cache, ln func(ctx context.Context, key string) (any, error), ...) (*BloomFilterCache, error) + func (bfc *BloomFilterCache) Get(ctx context.Context, key string) (any, error) + type Cache interface + ClearAll func(ctx context.Context) error + Decr func(ctx context.Context, key string) error + Delete func(ctx context.Context, key string) error + Get func(ctx context.Context, key string) (interface{}, error) + GetMulti func(ctx context.Context, keys []string) ([]interface{}, error) + Incr func(ctx context.Context, key string) error + IsExist func(ctx context.Context, key string) (bool, error) + Put func(ctx context.Context, key string, val interface{}, timeout time.Duration) error + StartAndGC func(config string) error + func NewCache(adapterName, config string) (adapter Cache, err error) + func NewFileCache() Cache + func NewMemoryCache() Cache + func NewRandomExpireCache(adapter Cache, opts ...RandomExpireCacheOption) Cache + func NewReadThroughCache(cache Cache, expiration time.Duration, ...) (Cache, error) + func NewSingleflightCache(c Cache, expiration time.Duration, ...) (Cache, error) + type FileCache struct + CachePath string + DirectoryLevel int + EmbedExpiry int + FileSuffix string + func (fc *FileCache) ClearAll(context.Context) error + func (fc *FileCache) Decr(ctx context.Context, key string) error + func (fc *FileCache) Delete(ctx context.Context, key string) error + func (fc *FileCache) Get(ctx context.Context, key string) (interface{}, error) + func (fc *FileCache) GetMulti(ctx context.Context, keys []string) ([]interface{}, error) + func (fc *FileCache) Incr(ctx context.Context, key string) error + func (fc *FileCache) Init() error + func (fc *FileCache) IsExist(ctx context.Context, key string) (bool, error) + func (fc *FileCache) Put(ctx context.Context, key string, val interface{}, timeout time.Duration) error + func (fc *FileCache) StartAndGC(config string) error + type FileCacheItem struct + Data interface{} + Expired time.Time + Lastaccess time.Time + type Instance func() Cache + type MemoryCache struct + Every int + func (bc *MemoryCache) ClearAll(context.Context) error + func (bc *MemoryCache) Decr(ctx context.Context, key string) error + func (bc *MemoryCache) Delete(ctx context.Context, key string) error + func (bc *MemoryCache) Get(ctx context.Context, key string) (interface{}, error) + func (bc *MemoryCache) GetMulti(ctx context.Context, keys []string) ([]interface{}, error) + func (bc *MemoryCache) Incr(ctx context.Context, key string) error + func (bc *MemoryCache) IsExist(ctx context.Context, key string) (bool, error) + func (bc *MemoryCache) Put(ctx context.Context, key string, val interface{}, timeout time.Duration) error + func (bc *MemoryCache) StartAndGC(config string) error + type MemoryItem struct + type RandomExpireCache struct + func (rec *RandomExpireCache) Put(ctx context.Context, key string, val interface{}, timeout time.Duration) error + type RandomExpireCacheOption func(*RandomExpireCache) + func WithRandomExpireOffsetFunc(fn func() time.Duration) RandomExpireCacheOption + type SingleflightCache struct + func (s *SingleflightCache) Get(ctx context.Context, key string) (any, error) + type WriteDeleteCache struct + func NewWriteDeleteCache(cache Cache, fn func(ctx context.Context, key string, val any) error) (*WriteDeleteCache, error) + func (w *WriteDeleteCache) Set(ctx context.Context, key string, val any) error + type WriteDoubleDeleteCache struct + func NewWriteDoubleDeleteCache(cache Cache, interval, timeout time.Duration, ...) (*WriteDoubleDeleteCache, error) + func (c *WriteDoubleDeleteCache) Set(ctx context.Context, key string, val any) error + type WriteDoubleDeleteCacheOption func(c *WriteDoubleDeleteCache) + type WriteThroughCache struct + func NewWriteThroughCache(cache Cache, fn func(ctx context.Context, key string, val any) error) (*WriteThroughCache, error) + func (w *WriteThroughCache) Set(ctx context.Context, key string, val any, expiration time.Duration) error