From 4abb511db30ffc01b94013434e1d941a1e22cef1 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 22 Mar 2021 22:33:07 -0700 Subject: [PATCH] make a local copy of the in memory cached data --- weed/util/chunk_cache/chunk_cache_in_memory.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weed/util/chunk_cache/chunk_cache_in_memory.go b/weed/util/chunk_cache/chunk_cache_in_memory.go index 1eb00e1fa..5f26b8c78 100644 --- a/weed/util/chunk_cache/chunk_cache_in_memory.go +++ b/weed/util/chunk_cache/chunk_cache_in_memory.go @@ -32,5 +32,7 @@ func (c *ChunkCacheInMemory) GetChunk(fileId string) []byte { } func (c *ChunkCacheInMemory) SetChunk(fileId string, data []byte) { - c.cache.Set(fileId, data, time.Hour) + localCopy := make([]byte, len(data)) + copy(localCopy, data) + c.cache.Set(fileId, localCopy, time.Hour) }