cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStats

type CacheStats struct {
	Hits      int64
	Misses    int64
	Evictions int64
	Size      int
	HitRate   float64
}

CacheStats holds cache performance metrics

type Config

type Config struct {
	Enabled   bool
	TTL       time.Duration
	MaxSizeMB int64
}

Config holds cache configuration

type Manager

type Manager interface {
	// Categories
	GetCategories() interface{}
	SetCategories(categories interface{})

	// Agents
	GetAgents(category string) interface{}
	SetAgents(category string, agents interface{})
	GetAgent(agentID string) interface{}
	SetAgent(agentID string, agent interface{})

	// Agent-to-category mapping for fast lookups
	GetAgentCategory(agentID string) string
	SetAgentCategory(agentID string, category string)

	// General operations
	Clear()
	IsExpired(key string) bool
	Size() int
	GetStats() CacheStats
}

Manager defines the interface for cache operations Uses interface{} to avoid import cycles - type assertions handled by callers

func NewManager

func NewManager(config Config) (Manager, error)

NewManager creates a new cache manager

type MockManager

type MockManager struct {

	// Call tracking
	GetCategoriesCalls    int
	SetCategoriesCalls    int
	GetAgentsCalls        []string
	SetAgentsCalls        []string
	GetAgentCalls         []string
	SetAgentCalls         []string
	GetAgentCategoryCalls []string
	SetAgentCategoryCalls []string
	ClearCalls            int
	IsExpiredCalls        []string
	SizeCalls             int
	GetStatsCalls         int
	// contains filtered or unexported fields
}

MockManager implements Manager interface for testing

func NewMockManager

func NewMockManager() *MockManager

NewMockManager creates a new mock cache manager

func (*MockManager) Clear

func (m *MockManager) Clear()

Clear removes all cached data

func (*MockManager) GetAgent

func (m *MockManager) GetAgent(agentID string) interface{}

GetAgent retrieves a cached agent by ID

func (*MockManager) GetAgentCategory

func (m *MockManager) GetAgentCategory(agentID string) string

GetAgentCategory retrieves the cached category for an agent

func (*MockManager) GetAgents

func (m *MockManager) GetAgents(category string) interface{}

GetAgents retrieves cached agents for a category

func (*MockManager) GetCallCounts

func (m *MockManager) GetCallCounts() map[string]int

GetCallCounts returns call counts for testing

func (*MockManager) GetCategories

func (m *MockManager) GetCategories() interface{}

GetCategories retrieves cached categories

func (*MockManager) GetStats

func (m *MockManager) GetStats() CacheStats

GetStats returns cache performance statistics

func (*MockManager) IsExpired

func (m *MockManager) IsExpired(key string) bool

IsExpired checks if a cache key is expired

func (*MockManager) Reset

func (m *MockManager) Reset()

Reset clears all call tracking and cached data

func (*MockManager) SetAgent

func (m *MockManager) SetAgent(agentID string, agent interface{})

SetAgent caches an individual agent

func (*MockManager) SetAgentCategory

func (m *MockManager) SetAgentCategory(agentID string, category string)

SetAgentCategory caches the category for an agent

func (*MockManager) SetAgents

func (m *MockManager) SetAgents(category string, agents interface{})

SetAgents caches agents for a category

func (*MockManager) SetCategories

func (m *MockManager) SetCategories(categories interface{})

SetCategories caches categories

func (*MockManager) SetDisabled

func (m *MockManager) SetDisabled(disabled bool)

SetDisabled configures whether the cache is disabled

func (*MockManager) SetExpired

func (m *MockManager) SetExpired(expired bool)

SetExpired configures whether items should be considered expired

func (*MockManager) Size

func (m *MockManager) Size() int

Size returns the number of items in cache

Jump to

Keyboard shortcuts

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