aboutsummaryrefslogtreecommitdiff
path: root/weed/util/chunk_cache
diff options
context:
space:
mode:
Diffstat (limited to 'weed/util/chunk_cache')
-rw-r--r--weed/util/chunk_cache/chunk_cache_in_memory.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/weed/util/chunk_cache/chunk_cache_in_memory.go b/weed/util/chunk_cache/chunk_cache_in_memory.go
index 2982d0979..dd101996e 100644
--- a/weed/util/chunk_cache/chunk_cache_in_memory.go
+++ b/weed/util/chunk_cache/chunk_cache_in_memory.go
@@ -5,11 +5,31 @@ import (
"time"
)
+var (
+ _ ChunkCache = &ChunkCacheInMemory{}
+)
+
// a global cache for recently accessed file chunks
type ChunkCacheInMemory struct {
cache *ccache.Cache
}
+func (c *ChunkCacheInMemory) ReadChunkAt(data []byte, fileId string, offset uint64) (n int, err error) {
+ return c.readChunkAt(data, fileId, offset)
+}
+
+func (c *ChunkCacheInMemory) IsInCache(fileId string, lockNeeded bool) (answer bool) {
+ item := c.cache.Get(fileId)
+ if item == nil {
+ return false
+ }
+ return true
+}
+
+func (c *ChunkCacheInMemory) GetMaxFilePartSizeInCache() (answer uint64) {
+ return 8 * 1024 * 1024
+}
+
func NewChunkCacheInMemory(maxEntries int64) *ChunkCacheInMemory {
pruneCount := maxEntries >> 3
if pruneCount <= 0 {