cache

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cache provides TTL caching for repeated filesystem discovery operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupExpiredFileSystemEntries

func CleanupExpiredFileSystemEntries()

CleanupExpiredFileSystemEntries cleans up expired file system entries.

func ClearFileSystemCache

func ClearFileSystemCache()

ClearFileSystemCache clears file system cache.

func GetDirectoryRoot

func GetDirectoryRoot(key string, resolver func() (string, error)) (string, error)

GetDirectoryRoot returns a cached directory root or resolves and caches it.

func GetFileExists

func GetFileExists(key string, checker func() bool) bool

GetFileExists returns a cached file existence check or runs and caches it.

func GetModulePath

func GetModulePath(key string, resolver func() (string, error)) (string, error)

GetModulePath returns a cached module path or resolves and caches it.

Types

type Entry

type Entry struct {
	Value     any
	ExpiresAt time.Time
}

Entry stores a cached value and its expiration time.

func (*Entry) IsExpired

func (e *Entry) IsExpired() bool

IsExpired reports whether the entry is past its expiration time.

type FileSystemCache

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

FileSystemCache is a small TTL cache for repeated filesystem lookups.

func NewFileSystemCache

func NewFileSystemCache(ttl time.Duration) *FileSystemCache

NewFileSystemCache creates a new file system cache.

func (*FileSystemCache) CleanupExpired

func (fsc *FileSystemCache) CleanupExpired()

CleanupExpired removes entries whose TTL has elapsed.

func (*FileSystemCache) Clear

func (fsc *FileSystemCache) Clear()

Clear removes all cached entries.

func (*FileSystemCache) Delete

func (fsc *FileSystemCache) Delete(key string)

Delete removes a value from the cache.

func (*FileSystemCache) Get

func (fsc *FileSystemCache) Get(key string) (any, bool)

Get returns a cached value when it exists and has not expired.

func (*FileSystemCache) Set

func (fsc *FileSystemCache) Set(key string, value any)

Set stores a value under key using the cache TTL.

Jump to

Keyboard shortcuts

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