make a local copy of the in memory cached data

This commit is contained in:
Chris Lu 2021-03-22 22:33:07 -07:00
parent 3cbc40fa48
commit 4abb511db3

View file

@ -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)
}