SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
avoid duplicated setting chunks into cache
Chris Lu2a1f396df5ab
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.goindex ead7a8d0b6..48e4bfb0d1 100644--- a/weed/util/chunk_cache/chunk_cache.go+++ b/weed/util/chunk_cache/chunk_cache.go@@ -54,6 +54,10 @@ func (c *ChunkCache) GetChunk(fileId string) (data []byte) {c.RLock()defer c.RUnlock()+ return c.doGetChunk(fileId)+}++func (c *ChunkCache) doGetChunk(fileId string) (data []byte) {if data = c.memCache.GetChunk(fileId); data != nil {return data}@@ -86,6 +90,13 @@ func (c *ChunkCache) SetChunk(fileId string, data []byte) {c.Lock()defer c.Unlock()+ if existingData := c.doGetChunk(fileId); len(existingData)==0{+ c.doSetChunk(fileId, data)+ }+}++func (c *ChunkCache) doSetChunk(fileId string, data []byte) {+c.memCache.SetChunk(fileId, data)if len(c.diskCaches) == 0 {