Documentation
¶
Index ¶
Constants ¶
View Source
const ( DriverMemory = "memory" NoExpiration = -1 * time.Second )
Variables ¶
View Source
var ( // ErrInvalidCacheDriver is returned when an unsupported cache driver is provided. ErrInvalidCacheDriver = errors.New("invalid cache driver") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Get returns the value for the given key.
Get(ctx context.Context, key string) (any, error)
// GetByPattern returns all values matching the given key pattern.
GetByPattern(ctx context.Context, keyPattern string) (map[string]any, error)
// Set stores a value with the given key and TTL.
Set(ctx context.Context, key string, value any, ttl time.Duration) error
// Delete removes the value for the given key.
Delete(ctx context.Context, key string) error
}
Cache defines a generic interface for cache operations.
type Config ¶
type Config struct {
// Driver is the type of cache backend (e.g., "memory").
Driver string `yaml:"driver" json:"driver"`
// InMemory is the configuration for the in-memory cache backend.
InMemory *inmemory.Config `yaml:"inmemory" json:"inmemory"`
}
Config is the configuration for the cache client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for in-memory caching.
Click to show internal directories.
Click to hide internal directories.