feat: add upstream and verbose flags to command line interface
All checks were successful
Release Tag / release (push) Successful in 13s
All checks were successful
Release Tag / release (push) Successful in 13s
feat: add upstream support allowing to chain cache servers if needed fix: tweaked garbage collection to be better
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package steamcache
|
||||
|
||||
import (
|
||||
"runtime/debug"
|
||||
"s1d3sw1ped/SteamCache2/vfs"
|
||||
"s1d3sw1ped/SteamCache2/vfs/cachestate"
|
||||
"time"
|
||||
@@ -8,9 +9,13 @@ import (
|
||||
"golang.org/x/exp/rand"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Set the GC percentage to 50%. This is a good balance between performance and memory usage.
|
||||
debug.SetGCPercent(50)
|
||||
}
|
||||
|
||||
// RandomGC randomly deletes files until we've reclaimed enough space.
|
||||
func randomgc(vfss vfs.VFS, size uint) (uint, uint) {
|
||||
|
||||
// Randomly delete files until we've reclaimed enough space.
|
||||
random := func(vfss vfs.VFS, stats []*vfs.FileInfo) int64 {
|
||||
randfile := stats[rand.Intn(len(stats))]
|
||||
@@ -29,16 +34,16 @@ func randomgc(vfss vfs.VFS, size uint) (uint, uint) {
|
||||
|
||||
stats := vfss.StatAll()
|
||||
for {
|
||||
reclaimed += random(vfss, stats)
|
||||
deletions++
|
||||
if reclaimed >= targetreclaim {
|
||||
break
|
||||
}
|
||||
reclaimed += random(vfss, stats)
|
||||
deletions++
|
||||
}
|
||||
|
||||
return uint(reclaimed), uint(deletions)
|
||||
}
|
||||
|
||||
func cachehandler(fi *vfs.FileInfo, cs cachestate.CacheState) bool {
|
||||
return time.Since(fi.AccessTime()) < time.Minute*10 // Put files in the cache if they've been accessed twice in the last 10 minutes
|
||||
return time.Since(fi.AccessTime()) < time.Second*10 // Put hot files in the fast vfs if equipped
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user