Documentation
¶
Overview ¶
Package cache provides caching annotations for SQL queries.
Package cache provides a runtime cache interface for query result caching.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Annotation ¶
Annotation represents a parsed cache directive.
func ParseAnnotation ¶
func ParseAnnotation(line string) *Annotation
ParseAnnotation parses a cache annotation from a comment line. Returns nil if the line is not a cache annotation.
func ParseAnnotations ¶
func ParseAnnotations(lines []string) *Annotation
ParseAnnotations extracts cache annotations from comment lines.
func (*Annotation) ToConfig ¶
func (a *Annotation) ToConfig() CacheConfig
ToConfig converts an annotation to a full cache config.
type Cache ¶
type Cache interface {
// Get retrieves a value from the cache.
Get(ctx context.Context, key string) (any, bool)
// Set stores a value in the cache with the given TTL.
Set(ctx context.Context, key string, value any, ttl time.Duration)
// Delete removes a value from the cache.
Delete(ctx context.Context, key string)
// Invalidate removes all values matching the given pattern.
Invalidate(ctx context.Context, pattern string)
}
Cache is the interface for query result caching.
type CacheConfig ¶
CacheConfig holds cache configuration parsed from SQL comments.
Click to show internal directories.
Click to hide internal directories.