cache

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache provides the CacheEntry and Cache interface used by the response-cache plugin. The default in-process implementation is MemoryCache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(key string) (*providers.Response, bool)
	Set(key string, resp *providers.Response)
	Delete(key string)
	Len() int
	Clear()
}

Cache defines the interface for response caching.

type Memory

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

Memory is a thread-safe in-memory LRU cache with TTL expiration.

func NewMemory

func NewMemory(capacity int, ttl time.Duration) *Memory

NewMemory creates a new in-memory LRU cache.

func (*Memory) Clear

func (m *Memory) Clear()

Clear removes all entries from the cache.

func (*Memory) Delete

func (m *Memory) Delete(key string)

Delete removes an entry from the cache.

func (*Memory) Get

func (m *Memory) Get(key string) (*providers.Response, bool)

Get returns the cached response for key, or false if missing or expired.

func (*Memory) Len

func (m *Memory) Len() int

Len returns the number of entries currently in the cache.

func (*Memory) Set

func (m *Memory) Set(key string, resp *providers.Response)

Set stores a response in the cache with the configured TTL.

Jump to

Keyboard shortcuts

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