Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("cache miss")
ErrCacheMiss is returned when a key is not found in the cache
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Get retrieves a value from the cache
Get(ctx context.Context, key string) ([]byte, error)
// Set stores a value in the cache with optional expiration
// If ttl is 0, the value will not be cached
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
// Close releases any resources used by the cache
Close() error
}
Cache defines the interface for caching data
type MemoryCache ¶ added in v1.2.0
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements the Cache interface using RAM
func NewMemoryClient ¶ added in v1.2.0
func NewMemoryClient() *MemoryCache
NewMemoryClient creates a new cache client
func (*MemoryCache) Close ¶ added in v1.2.0
func (c *MemoryCache) Close() error
Close releases the memory
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache implements the Cache interface using Redis
func NewRedisClient ¶
func NewRedisClient(ctx context.Context, addr string) (*RedisCache, error)
NewRedisClient creates a new Redis client
Click to show internal directories.
Click to hide internal directories.