Documentation
¶
Overview ¶
Package adapter provides concrete core/cache.ExternalCache implementations for the external cache's supported backends: Redis (RedisCache) and Memcached (MemcachedCache). cache.NewExternal selects and constructs one of these from Options; nothing downstream of that composition point imports this package directly — everything else depends only on the core/cache.ExternalCache interface.
The two backends differ in one structurally important way: Redis supports key enumeration (DelPrefix scans and deletes matching keys), while Memcached does not (DelPrefix is a no-op there). This is safe because ObjectCache's generation-scoped keys are the real correctness guarantee — a stale entry simply expires via TTL rather than being explicitly invalidated.
Index ¶
- type MemcachedCache
- func (c *MemcachedCache) Del(ctx context.Context, key string) error
- func (c *MemcachedCache) DelPrefix(ctx context.Context, prefix string) error
- func (c *MemcachedCache) Get(ctx context.Context, key string, into any) (bool, error)
- func (c *MemcachedCache) Set(ctx context.Context, key string, val any, ttl time.Duration) error
- type MemcachedConfig
- type RedisCache
- func (c *RedisCache) Del(ctx context.Context, key string) error
- func (c *RedisCache) DelPrefix(ctx context.Context, prefix string) error
- func (c *RedisCache) Get(ctx context.Context, key string, into any) (bool, error)
- func (c *RedisCache) Ping(ctx context.Context) error
- func (c *RedisCache) Set(ctx context.Context, key string, val any, ttl time.Duration) error
- type RedisConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemcachedCache ¶
type MemcachedCache struct {
// contains filtered or unexported fields
}
MemcachedCache implements core.ExternalCache backed by Memcached.
func NewMemcached ¶
func NewMemcached(cfg MemcachedConfig) *MemcachedCache
NewMemcached constructs a MemcachedCache connected to cfg's servers.
func (*MemcachedCache) DelPrefix ¶
func (c *MemcachedCache) DelPrefix(ctx context.Context, prefix string) error
DelPrefix: Memcached cannot enumerate keys, so prefix invalidation is a no-op here. Generation-scoped keys (see cache.ObjectCache) are the correctness guarantee on this backend — stale entries expire via TTL.
type MemcachedConfig ¶
type MemcachedConfig struct {
Servers []string // host:port
}
MemcachedConfig holds connection settings for the Memcached backend.
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache implements cache.ExternalCache backed by Redis.
func NewRedis ¶
func NewRedis(cfg RedisConfig) *RedisCache
NewRedis constructs a RedisCache connected per cfg.
func (*RedisCache) DelPrefix ¶
func (c *RedisCache) DelPrefix(ctx context.Context, prefix string) error
type RedisConfig ¶
RedisConfig holds connection settings for the Redis backend.