cache

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides caching for AQL query results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyFromQuery

func KeyFromQuery(query string, productID string) string

KeyFromQuery generates a cache key from a query string and options.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache provides in-memory caching for query results.

func New

func New(opts Options) *Cache

New creates a new cache with the given options.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all entries from the cache.

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes an entry from the cache.

func (*Cache) Get

func (c *Cache) Get(key string) *result.Result

Get retrieves a cached result by key. Returns nil if the entry doesn't exist or has expired.

func (*Cache) Set

func (c *Cache) Set(key string, res *result.Result)

Set stores a result in the cache.

func (*Cache) Size

func (c *Cache) Size() int

Size returns the number of entries in the cache.

func (*Cache) Stats

func (c *Cache) Stats() Stats

Stats returns cache statistics.

type Options

type Options struct {
	// TTL is the time-to-live for cache entries. Default: 5 minutes.
	TTL time.Duration

	// MaxSize is the maximum number of entries. Default: 100.
	MaxSize int
}

Options configures the cache.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns default cache options.

type Stats

type Stats struct {
	Size    int
	Expired int
	MaxSize int
	TTL     time.Duration
}

Stats contains cache statistics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL