cache

package
v0.0.0-...-a1f8bd1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache provides thread-safe caching with TTL support

func NewCache

func NewCache(logger logger.Logger, defaultTTL time.Duration) *Cache

NewCache creates a new cache instance

func (*Cache) Clear

func (c *Cache) Clear(ctx context.Context)

Clear removes all entries from the cache

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string)

Delete removes a key from the cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (interface{}, bool)

Get retrieves a value from the cache

func (*Cache) GetOrSet

func (c *Cache) GetOrSet(ctx context.Context, key string, factory func() (interface{}, error), ttl ...time.Duration) (interface{}, error)

GetOrSet retrieves a value or sets it if not found

func (*Cache) HashKey

func (c *Cache) HashKey(components ...string) string

HashKey creates a consistent hash key from multiple components

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, value interface{}, ttl ...time.Duration)

Set stores a value in the cache with optional custom TTL

func (*Cache) Stats

func (c *Cache) Stats() map[string]interface{}

Stats returns cache statistics

type CacheEntry

type CacheEntry struct {
	Value       interface{} `json:"value"`
	ExpiresAt   time.Time   `json:"expires_at"`
	CreatedAt   time.Time   `json:"created_at"`
	AccessCount int64       `json:"access_count"`
	LastAccess  time.Time   `json:"last_access"`
}

CacheEntry represents a cached item with expiration

type CacheManager

type CacheManager struct {
	EmbeddingsCache    *Cache
	LLMResponseCache   *Cache
	SchemaCache        *Cache
	DocumentationCache *Cache
	// contains filtered or unexported fields
}

CacheManager manages multiple specialized caches

func NewCacheManager

func NewCacheManager(logger logger.Logger) *CacheManager

NewCacheManager creates a new cache manager with pre-configured caches

func (*CacheManager) ClearAll

func (cm *CacheManager) ClearAll(ctx context.Context)

ClearAll clears all managed caches

func (*CacheManager) GenerateCacheKey

func (cm *CacheManager) GenerateCacheKey(prefix string, components ...string) string

GenerateCacheKey creates a consistent cache key for different contexts

func (*CacheManager) GetGlobalStats

func (cm *CacheManager) GetGlobalStats() map[string]interface{}

GetGlobalStats returns statistics for all caches

Jump to

Keyboard shortcuts

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