Documentation
¶
Overview ¶
Package cache provides caching implementations for Warden check results.
Index ¶
- type Memory
- func (m *Memory) Get(_ context.Context, tenantID string, req *warden.CheckRequest) (*warden.CheckResult, bool)
- func (m *Memory) InvalidateSubject(_ context.Context, tenantID string, subjectKind warden.SubjectKind, ...)
- func (m *Memory) InvalidateTenant(_ context.Context, tenantID string)
- func (m *Memory) Set(_ context.Context, tenantID string, req *warden.CheckRequest, ...)
- type MemoryOption
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.