Documentation
¶
Overview ¶
Package cache provides file-based caching with TTL expiry.
Index ¶
- func CacheDir() (string, error)
- func CleanupSessions(s *Store, activeIDs []string) error
- func Get[T any](s *Store, key string, dst *T) bool
- func Invalidate(s *Store, key string)
- func RecordSession(s *Store, sessionID string, now time.Time) error
- func SessionTimestamps(s *Store) map[string]time.Time
- func Set[T any](s *Store, key string, value T) error
- type CachedEligibilityLister
- type EligibilityLister
- type GroupsEligibilityLister
- type Logger
- type SessionRecord
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupSessions ¶ added in v0.6.0
CleanupSessions removes entries for sessions not in the activeIDs list.
func Get ¶
Get reads a cached value for key into dst. Returns true on hit, false on miss/expiry/error.
func RecordSession ¶ added in v0.6.0
RecordSession stores the elevation timestamp for a session ID. It performs a read-modify-write on the session timestamps cache entry.
func SessionTimestamps ¶ added in v0.6.0
SessionTimestamps returns a map of sessionID -> elevatedAt for all tracked sessions. Entries older than maxSessionAge are filtered out. Returns an empty map on error.
Types ¶
type CachedEligibilityLister ¶
type CachedEligibilityLister struct {
// contains filtered or unexported fields
}
CachedEligibilityLister decorates eligibility listers with file-based caching. It implements both EligibilityLister and GroupsEligibilityLister.
func NewCachedEligibilityLister ¶
func NewCachedEligibilityLister( cloudInner EligibilityLister, groupsInner GroupsEligibilityLister, store *Store, refresh bool, log Logger, ) *CachedEligibilityLister
NewCachedEligibilityLister creates a new caching decorator. Either inner may be nil if that type of listing is not needed. When refresh is true, the cache read is bypassed but the API response is still cached. Logger is optional — pass nil for silent operation.
func (*CachedEligibilityLister) ListEligibility ¶
func (c *CachedEligibilityLister) ListEligibility(ctx context.Context, csp models.CSP) (*models.EligibilityResponse, error)
ListEligibility checks the cache first, then falls through to the inner lister.
func (*CachedEligibilityLister) ListGroupsEligibility ¶
func (c *CachedEligibilityLister) ListGroupsEligibility(ctx context.Context, csp models.CSP) (*models.GroupsEligibilityResponse, error)
ListGroupsEligibility checks the cache first, then falls through to the inner lister.
type EligibilityLister ¶
type EligibilityLister interface {
ListEligibility(ctx context.Context, csp models.CSP) (*models.EligibilityResponse, error)
}
EligibilityLister mirrors cmd.eligibilityLister to avoid import cycles.
type GroupsEligibilityLister ¶
type GroupsEligibilityLister interface {
ListGroupsEligibility(ctx context.Context, csp models.CSP) (*models.GroupsEligibilityResponse, error)
}
GroupsEligibilityLister mirrors cmd.groupsEligibilityLister to avoid import cycles.
type Logger ¶
type Logger interface {
Info(msg string, v ...interface{})
}
Logger interface for verbose output — satisfied by *common.IdsecLogger.
type SessionRecord ¶ added in v0.6.0
SessionRecord stores the timestamp when a session was elevated.