Enhance file metadata tracking and garbage collection logic
All checks were successful
Release Tag / release (push) Successful in 13s

- Added AccessCount field to FileInfo struct for improved tracking of file access frequency.
- Updated NewFileInfo and NewFileInfoFromOS functions to initialize AccessCount.
- Modified DiskFS and MemoryFS to preserve and increment AccessCount during file operations.
- Enhanced garbage collection methods (LRU, LFU, FIFO, Largest, Smallest, Hybrid) to utilize AccessCount for more effective space reclamation.
This commit is contained in:
2025-07-19 09:07:49 -05:00
parent 1187f05c77
commit 6919358eab
5 changed files with 92 additions and 65 deletions

View File

@@ -7,27 +7,30 @@ import (
)
type FileInfo struct {
name string
size int64
MTime time.Time
ATime time.Time
name string
size int64
MTime time.Time
ATime time.Time
AccessCount int64 // Number of times the file has been accessed
}
func NewFileInfo(key string, size int64, modTime time.Time) *FileInfo {
return &FileInfo{
name: key,
size: size,
MTime: modTime,
ATime: time.Now(),
name: key,
size: size,
MTime: modTime,
ATime: time.Now(),
AccessCount: 0,
}
}
func NewFileInfoFromOS(f os.FileInfo, key string) *FileInfo {
return &FileInfo{
name: key,
size: f.Size(),
MTime: f.ModTime(),
ATime: time.Now(),
name: key,
size: f.Size(),
MTime: f.ModTime(),
ATime: time.Now(),
AccessCount: 0,
}
}