aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-03-22 22:33:07 -0700
committerChris Lu <chris.lu@gmail.com>2021-03-22 22:33:07 -0700
commit4abb511db30ffc01b94013434e1d941a1e22cef1 (patch)
treef6b4fe0519e3c66e5befb2ee591ee41592f1fb9a
parent3cbc40fa48689511dbb5a953399218e1a296a874 (diff)
downloadseaweedfs-4abb511db30ffc01b94013434e1d941a1e22cef1.tar.xz
seaweedfs-4abb511db30ffc01b94013434e1d941a1e22cef1.zip
make a local copy of the in memory cached data
-rw-r--r--weed/util/chunk_cache/chunk_cache_in_memory.go4
1 files changed, 3 insertions, 1 deletions
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)
}