cache

package
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides TTL-based caching for API metadata.

Index

Constants

View Source
const (
	// DefaultTTLHours is the default cache TTL if not configured
	DefaultTTLHours = 24
	// CacheDir is the subdirectory within config for cache files
	CacheDir = "cache"
	// DrivesFile is the cache file for shared drives
	DrivesFile = "drives.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache provides TTL-based caching for API metadata

func New

func New(ttlHours int) (*Cache, error)

New creates a new Cache instance

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all cached data

func (*Cache) GetDir

func (c *Cache) GetDir() string

GetDir returns the cache directory path

func (*Cache) GetDrives

func (c *Cache) GetDrives() ([]*CachedDrive, error)

GetDrives returns cached shared drives, or nil if cache is stale or missing

func (*Cache) GetStatus

func (c *Cache) GetStatus() (*Status, error)

GetStatus returns the current cache status

func (*Cache) SetDrives

func (c *Cache) SetDrives(drives []*CachedDrive) error

SetDrives updates the cached shared drives

type CachedDrive

type CachedDrive struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

CachedDrive represents a cached shared drive entry

type DriveCache

type DriveCache struct {
	CachedAt time.Time      `json:"cached_at"`
	TTLHours int            `json:"ttl_hours"`
	Drives   []*CachedDrive `json:"drives"`
}

DriveCache represents the cached shared drives data

type FileInfo

type FileInfo struct {
	Path      string    `json:"path"`
	CachedAt  time.Time `json:"cached_at"`
	ExpiresAt time.Time `json:"expires_at"`
	IsStale   bool      `json:"is_stale"`
	Count     int       `json:"count"`
}

FileInfo contains information about a cache file

type Status

type Status struct {
	Dir         string    `json:"dir"`
	TTLHours    int       `json:"ttl_hours"`
	DrivesCache *FileInfo `json:"drives_cache,omitempty"`
}

Status returns information about the cache state

Jump to

Keyboard shortcuts

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