cache

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides caching implementations for Warden check results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

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

Memory is an in-memory LRU-like cache with TTL-based expiration.

func NewMemory

func NewMemory(opts ...MemoryOption) *Memory

NewMemory creates a new in-memory cache.

func (*Memory) Get

func (m *Memory) Get(_ context.Context, tenantID string, req *warden.CheckRequest) (*warden.CheckResult, bool)

Get returns a cached check result.

func (*Memory) InvalidateSubject

func (m *Memory) InvalidateSubject(_ context.Context, tenantID string, subjectKind warden.SubjectKind, subjectID string)

InvalidateSubject removes all cached results for a specific subject.

func (*Memory) InvalidateTenant

func (m *Memory) InvalidateTenant(_ context.Context, tenantID string)

InvalidateTenant removes all cached results for a tenant.

func (*Memory) Set

func (m *Memory) Set(_ context.Context, tenantID string, req *warden.CheckRequest, result *warden.CheckResult)

Set stores a check result in the cache.

type MemoryOption

type MemoryOption func(*Memory)

MemoryOption configures the memory cache.

func WithMaxSize

func WithMaxSize(n int) MemoryOption

WithMaxSize sets the maximum number of cache entries.

func WithTTL

func WithTTL(ttl time.Duration) MemoryOption

WithTTL sets the cache entry time-to-live.

Jump to

Keyboard shortcuts

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