Documentation
¶
Index ¶
- type CacheConfig
- type CacheLevel
- type DataLayerInterface
- type DefaultLoggerImpl
- type LoggerInterface
- type MemoryLayer
- func (m *MemoryLayer) BatchDeleteKeys(ctx context.Context, keys []string) error
- func (m *MemoryLayer) BatchGetValues(ctx context.Context, keys []string) ([]string, error)
- func (m *MemoryLayer) BatchKeyExist(ctx context.Context, keys []string) (bool, error)
- func (m *MemoryLayer) BatchSetKeys(ctx context.Context, kvs []util.Kv) error
- func (m *MemoryLayer) CleanCache(ctx context.Context) error
- func (m *MemoryLayer) DeleteKey(ctx context.Context, key string) error
- func (m *MemoryLayer) DeleteKeysWithPrefix(ctx context.Context, keyPrefix string) error
- func (m *MemoryLayer) GetValue(ctx context.Context, key string) (string, error)
- func (m *MemoryLayer) Init(conf *CacheConfig, prefix string) error
- func (m *MemoryLayer) KeyExists(ctx context.Context, key string) (bool, error)
- func (m *MemoryLayer) SetKey(ctx context.Context, kv util.Kv) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶
type CacheConfig struct {
// Domain namespace
Domain string
// CacheLevel there are 2 types of cache and 4 kinds of cache option
CacheLevel CacheLevel
// CacheStorage choose proper storage medium
CacheStorage DataLayerInterface
// Tables only cache data within given data tables (cache all if empty)
Tables []string
// InvalidateWhenUpdate
// if user update/delete/create something in DB, we invalidate all cached data to ensure consistency,
// else we do nothing to outdated cache.
InvalidateWhenUpdate bool
// CacheTTL cache ttl in ms, where 0 represents forever
CacheTTL int64
// CacheMaxItemCnt for given query, if objects retrieved are more than this cnt,
// then we choose not to cache for this query. 0 represents caching all queries.
CacheMaxItemCnt int64
// CacheSize maximal items in primary cache (only works in MEMORY storage)
CacheSize int
// DebugMode indicate if we're in debug mode (will print access log)
DebugMode bool
// DebugLogger
DebugLogger LoggerInterface
}
type CacheLevel ¶
type CacheLevel int
const ( CacheLevelOff CacheLevel = 0 CacheLevelOnlyPrimary CacheLevel = 1 CacheLevelOnlySearch CacheLevel = 2 CacheLevelAll CacheLevel = 3 )
type DataLayerInterface ¶
type DataLayerInterface interface {
Init(config *CacheConfig, prefix string) error
// read
BatchKeyExist(ctx context.Context, keys []string) (bool, error)
KeyExists(ctx context.Context, key string) (bool, error)
GetValue(ctx context.Context, key string) (string, error)
BatchGetValues(ctx context.Context, keys []string) ([]string, error)
// write
CleanCache(ctx context.Context) error
DeleteKeysWithPrefix(ctx context.Context, keyPrefix string) error
DeleteKey(ctx context.Context, key string) error
BatchDeleteKeys(ctx context.Context, keys []string) error
BatchSetKeys(ctx context.Context, kvs []util.Kv) error
SetKey(ctx context.Context, kv util.Kv) error
}
type DefaultLoggerImpl ¶
type DefaultLoggerImpl struct {
// contains filtered or unexported fields
}
func (*DefaultLoggerImpl) CtxError ¶
func (l *DefaultLoggerImpl) CtxError(ctx context.Context, format string, v ...interface{})
func (*DefaultLoggerImpl) CtxInfo ¶
func (l *DefaultLoggerImpl) CtxInfo(ctx context.Context, format string, v ...interface{})
func (*DefaultLoggerImpl) SetIsDebug ¶
func (l *DefaultLoggerImpl) SetIsDebug(d bool)
type LoggerInterface ¶
type MemoryLayer ¶
type MemoryLayer struct {
// contains filtered or unexported fields
}
func (*MemoryLayer) BatchDeleteKeys ¶
func (m *MemoryLayer) BatchDeleteKeys(ctx context.Context, keys []string) error
func (*MemoryLayer) BatchGetValues ¶
func (*MemoryLayer) BatchKeyExist ¶
func (*MemoryLayer) BatchSetKeys ¶
func (*MemoryLayer) CleanCache ¶
func (m *MemoryLayer) CleanCache(ctx context.Context) error
func (*MemoryLayer) DeleteKey ¶
func (m *MemoryLayer) DeleteKey(ctx context.Context, key string) error
func (*MemoryLayer) DeleteKeysWithPrefix ¶
func (m *MemoryLayer) DeleteKeysWithPrefix(ctx context.Context, keyPrefix string) error
func (*MemoryLayer) Init ¶
func (m *MemoryLayer) Init(conf *CacheConfig, prefix string) error
Click to show internal directories.
Click to hide internal directories.