Documentation
¶
Index ¶
- Constants
- type CacheItem
- type CombinedCache
- type CombinedConfig
- type CustomZ
- type LocalCache
- type LocalConfig
- type MockZCache
- func (m *MockZCache) Decr(ctx context.Context, key string) (int64, error)
- func (m *MockZCache) Delete(ctx context.Context, key string) error
- func (m *MockZCache) Exists(ctx context.Context, keys ...string) (int64, error)
- func (m *MockZCache) Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (m *MockZCache) FlushAll(ctx context.Context) error
- func (m *MockZCache) Get(ctx context.Context, key string, data any) error
- func (m *MockZCache) GetStats() ZCacheStats
- func (m *MockZCache) HGet(ctx context.Context, key, field string) (string, error)
- func (m *MockZCache) HSet(ctx context.Context, key string, values ...any) (int64, error)
- func (m *MockZCache) Incr(ctx context.Context, key string) (int64, error)
- func (m *MockZCache) IsNotFoundError(err error) bool
- func (m *MockZCache) LPush(ctx context.Context, key string, values ...any) (int64, error)
- func (m *MockZCache) RPush(ctx context.Context, key string, values ...any) (int64, error)
- func (m *MockZCache) SAdd(ctx context.Context, key string, members ...any) (int64, error)
- func (m *MockZCache) SMembers(ctx context.Context, key string) ([]string, error)
- func (m *MockZCache) Set(ctx context.Context, key string, value any, ttl time.Duration) error
- func (m *MockZCache) SetupAndMonitorMetrics(appName string, metricsServer metrics.TaskMetrics, ...) []error
- func (m *MockZCache) TTL(ctx context.Context, key string) (time.Duration, error)
- func (m *MockZCache) ZIncrBy(ctx context.Context, key string, member string, increment float64) (float64, error)
- func (m *MockZCache) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]CustomZ, error)
- type MockZMutex
- type RedisStats
- type RemoteCache
- type RemoteConfig
- type StatsMetrics
- type ZCache
- type ZCacheStats
- type ZMutex
Constants ¶
View Source
const ( // Default Ristretto cache config DefaultNumCounters = int64(1e7) // 10M keys DefaultMaxCostMB = int64(1024) // 1GB DefaultBufferItems = int64(64) )
View Source
const KeySplitter = "/"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CombinedCache ¶
type CombinedCache interface {
ZCache
}
func NewCombinedCache ¶
func NewCombinedCache(combinedConfig *CombinedConfig) (CombinedCache, error)
type CombinedConfig ¶
type CombinedConfig struct {
Local *LocalConfig
Remote *RemoteConfig
GlobalLogger *logger.Logger
GlobalPrefix string
GlobalMetricServer metrics.TaskMetrics
GlobalStatsMetrics StatsMetrics
IsRemoteBestEffort bool
}
type LocalCache ¶
type LocalCache interface {
ZCache
}
func NewLocalCache ¶
func NewLocalCache(config *LocalConfig) (LocalCache, error)
type LocalConfig ¶
type LocalConfig struct {
Prefix string
Logger *logger.Logger
MetricServer metrics.TaskMetrics
StatsMetrics StatsMetrics
// Add Ristretto cache configuration
NumCounters int64 `json:"num_counters"` // default: 1e7
MaxCostMB int64 `json:"max_cost_mb"` // in MB, default: 1024 (1GB)
BufferItems int64 `json:"buffer_items"` // default: 64
}
func (*LocalConfig) ToRistrettoConfig ¶
func (c *LocalConfig) ToRistrettoConfig() *ristretto.Config
type MockZCache ¶
func (*MockZCache) GetStats ¶
func (m *MockZCache) GetStats() ZCacheStats
func (*MockZCache) IsNotFoundError ¶
func (m *MockZCache) IsNotFoundError(err error) bool
func (*MockZCache) SetupAndMonitorMetrics ¶
func (m *MockZCache) SetupAndMonitorMetrics(appName string, metricsServer metrics.TaskMetrics, updateInterval time.Duration) []error
func (*MockZCache) ZRevRangeWithScores ¶
type MockZMutex ¶
func (*MockZMutex) Lock ¶
func (m *MockZMutex) Lock() error
func (*MockZMutex) Name ¶
func (m *MockZMutex) Name() string
func (*MockZMutex) Unlock ¶
func (m *MockZMutex) Unlock() (bool, error)
type RedisStats ¶
type RemoteCache ¶
type RemoteCache interface {
ZCache
Incr(ctx context.Context, key string) (int64, error)
Decr(ctx context.Context, key string) (int64, error)
LPush(ctx context.Context, key string, values ...any) (int64, error)
RPush(ctx context.Context, key string, values ...any) (int64, error)
SMembers(ctx context.Context, key string) ([]string, error)
SAdd(ctx context.Context, key string, members ...any) (int64, error)
HSet(ctx context.Context, key string, values ...any) (int64, error)
HGet(ctx context.Context, key, field string) (string, error)
ZIncrBy(ctx context.Context, key string, member string, increment float64) (float64, error)
ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]CustomZ, error)
FlushAll(ctx context.Context) error
Exists(ctx context.Context, keys ...string) (int64, error)
Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)
TTL(ctx context.Context, key string) (time.Duration, error)
}
func NewRemoteCache ¶
func NewRemoteCache(config *RemoteConfig) (RemoteCache, error)
type RemoteConfig ¶
type RemoteConfig struct {
Network string
Addr string
Password string
DB int
DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
PoolSize int
MinIdleConns int
MaxConnAge time.Duration
PoolTimeout time.Duration
IdleTimeout time.Duration
IdleCheckFrequency time.Duration
Prefix string
Logger *logger.Logger
MetricServer metrics.TaskMetrics
StatsMetrics StatsMetrics
}
func (*RemoteConfig) ToRedisConfig ¶
func (c *RemoteConfig) ToRedisConfig() *redis.Options
type StatsMetrics ¶
type ZCacheStats ¶
type ZCacheStats struct {
Local *ristretto.Metrics
Remote *RedisStats
}
Click to show internal directories.
Click to hide internal directories.