Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileCache ¶
type FileCache struct {
Path string
}
FileCache is a cache backend that stores each key as a JSON file on disk.
func NewFileCache ¶
NewFileCache returns a file-based cache store.
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache is an in-process cache backed by a map with TTL-based expiry.
func NewMemoryCache ¶
func NewMemoryCache() *MemoryCache
NewMemoryCache returns an empty in-memory store.
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(key string) error
func (*MemoryCache) Flush ¶
func (c *MemoryCache) Flush() error
type RedisCache ¶
RedisCache is a cache backend backed by Redis.
func NewRedisCache ¶
func NewRedisCache(client *redis.Client) *RedisCache
NewRedisCache returns a Redis-backed cache store.
func (*RedisCache) Delete ¶
func (c *RedisCache) Delete(key string) error
func (*RedisCache) Flush ¶
func (c *RedisCache) Flush() error
type Store ¶
type Store interface {
Get(key string) (string, error)
Set(key string, value string, ttl time.Duration) error
Delete(key string) error
Flush() error
}
Store defines the cache contract.
func NewStore ¶
NewStore creates a cache Store for the given driver. If prefix is non-empty, all keys are automatically prefixed.
Supported drivers: "memory", "file", "redis". For "file": reads CACHE_FILE_PATH env (default: "storage/cache"). For "redis": reads REDIS_HOST, REDIS_PORT, REDIS_PASSWORD env.