cache

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 4 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 is a thread-safe LRU cache with TTL support and namespace invalidation.

func New

func New(maxSize int) *Cache

New creates a cache with the given max number of entries.

func (*Cache) Flush

func (c *Cache) Flush(resource allowlist.ResourceType) int

Flush removes all entries, optionally filtered by resource type.

func (*Cache) Get

func (c *Cache) Get(key string) *Entry

Get retrieves an entry by key. Returns nil if not found or expired.

func (*Cache) InvalidateNamespace

func (c *Cache) InvalidateNamespace(host, repo string, resource allowlist.ResourceType) int

InvalidateNamespace removes all entries matching the given host, repo, and resource type.

func (*Cache) Keys

func (c *Cache) Keys() []string

Keys returns all current cache keys (for debugging).

func (*Cache) OnEvict

func (c *Cache) OnEvict(fn func(key string))

OnEvict sets a callback that fires when an entry is evicted.

func (*Cache) Set

func (c *Cache) Set(entry *Entry)

Set stores an entry in the cache.

func (*Cache) Size

func (c *Cache) Size() int

Size returns the current number of cached entries.

type Entry

type Entry struct {
	Key      string
	Stdout   []byte
	Stderr   []byte
	ExitCode int
	CachedAt time.Time
	TTL      time.Duration
	Resource allowlist.ResourceType
	Host     string
	Repo     string
}

Entry is a cached response.

func (*Entry) IsExpired

func (e *Entry) IsExpired() bool

IsExpired returns true if the entry has outlived its TTL.

Jump to

Keyboard shortcuts

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