Documentation
¶
Index ¶
- Constants
- func BuildLines(path string, width, lines int, palette ThemePalette) []string
- func CacheKeyForSession(path string, width int, sizeBytes int64, updatedAtUnix int64) string
- func LinesBytes(lines []string) int64
- func LoadIndexEntry(path, key string) ([]string, bool, error)
- func ReadIndex(path string) (map[string]IndexRecord, bool, error)
- func RecordBytes(rec IndexRecord) int64
- func RewriteIndex(path string, entries map[string]IndexRecord, cap int, maxBytes int64) error
- func TrimIndexBytes(entries map[string]IndexRecord, totalBytes, maxBytes int64) int64
- func UpsertIndex(path string, cap int, record IndexRecord) error
- func WithIndexLock(lockPath string, timeout time.Duration, fn func() error) error
- type IndexRecord
- type ThemePalette
Constants ¶
View Source
const MaxIndexBytes = 8 << 20
MaxIndexBytes is the byte budget for preview index storage.
Variables ¶
This section is empty.
Functions ¶
func BuildLines ¶
func BuildLines(path string, width, lines int, palette ThemePalette) []string
BuildLines renders preview entries from one session file.
func CacheKeyForSession ¶
CacheKeyForSession derives a stable preview cache key from session metadata.
func LinesBytes ¶
LinesBytes returns raw string bytes occupied by preview lines.
func LoadIndexEntry ¶
LoadIndexEntry loads one cached preview by key.
func ReadIndex ¶
func ReadIndex(path string) (map[string]IndexRecord, bool, error)
ReadIndex reads all records. Corrupted lines are skipped and flagged.
func RecordBytes ¶
func RecordBytes(rec IndexRecord) int64
RecordBytes estimates one index record byte footprint.
func RewriteIndex ¶
RewriteIndex rewrites index with cap and byte-limit trimming.
func TrimIndexBytes ¶
func TrimIndexBytes(entries map[string]IndexRecord, totalBytes, maxBytes int64) int64
TrimIndexBytes evicts oldest records until byte budget is satisfied.
func UpsertIndex ¶
func UpsertIndex(path string, cap int, record IndexRecord) error
UpsertIndex inserts or updates one preview index record.
Types ¶
type IndexRecord ¶
type IndexRecord struct {
Key string `json:"key"`
Path string `json:"path"`
Width int `json:"width"`
SizeBytes int64 `json:"size_bytes"`
UpdatedAtUnix int64 `json:"updated_at_unix"`
TouchedAtUnix int64 `json:"touched_at_unix"`
Lines []string `json:"lines"`
}
IndexRecord is one preview index row.
Click to show internal directories.
Click to hide internal directories.