Documentation
¶
Index ¶
Constants ¶
View Source
const ( CacheTypeRedis CacheType = "redis" CacheTypeMemory = "memory" CacheTypeEtcd = "etcd" CacheTypeMemcache = "memcache" )
CacheType .
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { GetCache(ctx context.Context, key string) (string, error) SetCache(ctx context.Context, key, value string) error DeleteCache(ctx context.Context, key string) error Close() error }
Cache defines the interface for cache operations
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager ..
func NewCacheManager ¶
func NewCacheManager(arg *CacheMgrParams) (*CacheManager, error)
NewCacheManager ..
func (*CacheManager) Setup ¶
func (cm *CacheManager) Setup(arg *CacheMgrParams) error
Setup initialize the cache
type CacheMgrParams ¶
type CacheMgrParams struct { Type CacheType CacheAddrs string CacheUsername string CachePassword string KeyPrefix string Ttl time.Duration CleanInt time.Duration }
CacheMgrParams ..
type CaptCacheData ¶
type CaptCacheData struct { Data interface{} `json:"data"` Type int `json:"type"` Status int `json:"status"` }
CaptCacheData ..
type EtcdClient ¶
type EtcdClient struct {
// contains filtered or unexported fields
}
EtcdClient implements the Cache interface for etcd
func NewEtcdClient ¶
func NewEtcdClient(addrs, prefix string, ttl time.Duration, username, password string) (*EtcdClient, error)
NewEtcdClient ..
func (*EtcdClient) DeleteCache ¶
func (c *EtcdClient) DeleteCache(ctx context.Context, key string) error
DeleteCache ..
type MemcacheClient ¶
type MemcacheClient struct {
// contains filtered or unexported fields
}
MemcacheClient implements the Cache interface for Memcached
func NewMemcacheClient ¶
func NewMemcacheClient(addrs, prefix string, ttl time.Duration, username, password string) (*MemcacheClient, error)
NewMemcacheClient ..
func (*MemcacheClient) DeleteCache ¶
func (c *MemcacheClient) DeleteCache(ctx context.Context, key string) error
DeleteCache ..
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache is an in-memory cache with TTL and cleanup
func NewMemoryCache ¶
func NewMemoryCache(prefix string, ttl, cleanupInterval time.Duration) *MemoryCache
NewMemoryCache ..
func (*MemoryCache) DeleteCache ¶
func (c *MemoryCache) DeleteCache(ctx context.Context, key string) error
DeleteCache delete a value in memory cache
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
RedisClient implements the Cache interface for Redis
func NewRedisClient ¶
func NewRedisClient(addrs, prefix string, ttl time.Duration, username, password string) (*RedisClient, error)
NewRedisClient ..
func (*RedisClient) DeleteCache ¶
func (c *RedisClient) DeleteCache(ctx context.Context, key string) error
DeleteCache delete a value in Redis
Click to show internal directories.
Click to hide internal directories.