FUSE: add configurable in memory chunk cache size

This commit is contained in:
Chris Lu
2020-03-28 14:07:16 -07:00
parent 826bc0b7e3
commit a75d50bbb8
6 changed files with 24 additions and 15 deletions

View File

@@ -11,9 +11,13 @@ type ChunkCache struct {
cache *ccache.Cache
}
func NewChunkCache() *ChunkCache {
func NewChunkCache(maxEntries int64) *ChunkCache {
pruneCount := maxEntries >> 3
if pruneCount <= 0 {
pruneCount = 500
}
return &ChunkCache{
cache: ccache.New(ccache.Configure().MaxSize(1000).ItemsToPrune(100)),
cache: ccache.New(ccache.Configure().MaxSize(maxEntries).ItemsToPrune(uint32(pruneCount))),
}
}