cachehandler

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(bytes int64) string

FormatSize formats bytes to human-readable size

Types

type CacheEntry

type CacheEntry struct {
	CacheKey    string
	SourceFiles []string
	CachedAt    time.Time
	TotalRows   int64
	Tables      []string
	SizeBytes   int64
}

CacheEntry represents a cache entry for listing

type CacheHandler

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

CacheHandler manages data caching for files

func NewCacheHandler

func NewCacheHandler(cacheDir string, enabled bool) (*CacheHandler, error)

NewCacheHandler creates a new cache handler

func (*CacheHandler) ClearCache

func (h *CacheHandler) ClearCache() error

ClearCache removes all cache files

func (*CacheHandler) ClearCacheEntry

func (h *CacheHandler) ClearCacheEntry(cacheKey string) error

ClearCacheEntry removes a specific cache entry

func (*CacheHandler) GenerateCacheKey

func (h *CacheHandler) GenerateCacheKey(files []string) (string, error)

GenerateCacheKey creates a unique cache key based on file paths and modification times

func (*CacheHandler) GetCacheDir

func (h *CacheHandler) GetCacheDir() string

GetCacheDir returns the cache directory path

func (*CacheHandler) GetCachePath

func (h *CacheHandler) GetCachePath(cacheKey string) string

GetCachePath returns the path to the cache database for given files

func (*CacheHandler) GetCacheStats

func (h *CacheHandler) GetCacheStats() (int, int64, error)

GetCacheStats returns cache statistics

func (*CacheHandler) GetMetadataPath

func (h *CacheHandler) GetMetadataPath(cacheKey string) string

GetMetadataPath returns the path to the metadata file for given cache key

func (*CacheHandler) IsCacheValid

func (h *CacheHandler) IsCacheValid(files []string) (bool, string, error)

IsCacheValid checks if a valid cache exists for the given files

func (*CacheHandler) IsEnabled

func (h *CacheHandler) IsEnabled() bool

IsEnabled returns whether caching is enabled

func (*CacheHandler) ListCache

func (h *CacheHandler) ListCache() ([]CacheEntry, error)

ListCache returns all cache entries

func (*CacheHandler) ReadMetadata

func (h *CacheHandler) ReadMetadata(cacheKey string) (*CacheMetadata, error)

ReadMetadata reads cache metadata

func (*CacheHandler) SaveMetadata

func (h *CacheHandler) SaveMetadata(cacheKey string, files []string, tables []string, totalRows int64) error

SaveMetadata saves cache metadata

type CacheMetadata

type CacheMetadata struct {
	SourceFiles   []string  `json:"source_files"`
	ModTimes      []int64   `json:"mod_times"`
	CachedAt      time.Time `json:"cached_at"`
	CacheFile     string    `json:"cache_file"`
	TotalRows     int64     `json:"total_rows"`
	Tables        []string  `json:"tables"`
	FileHash      string    `json:"file_hash"`      // Hash of file paths + mod times
	FormatVersion int       `json:"format_version"` // For cache format compatibility
}

CacheMetadata stores information about a cached file

Jump to

Keyboard shortcuts

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