diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-06-27 11:59:12 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-06-27 11:59:15 -0700 |
| commit | a808b3b5df6944a5b3434032b5fdb0fe68211c11 (patch) | |
| tree | 3cdde1116914d9aa155236378bf607ad752db4dd | |
| parent | c3fed4fb6b3917d7d3b208bfdaf0f110053742b9 (diff) | |
| download | seaweedfs-a808b3b5df6944a5b3434032b5fdb0fe68211c11.tar.xz seaweedfs-a808b3b5df6944a5b3434032b5fdb0fe68211c11.zip | |
incase the memory data is too small
| -rw-r--r-- | weed/util/chunk_cache/chunk_cache.go | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.go index 325253837..3ae0f4ed5 100644 --- a/weed/util/chunk_cache/chunk_cache.go +++ b/weed/util/chunk_cache/chunk_cache.go @@ -46,10 +46,9 @@ func (c *ChunkCache) GetChunk(fileId string, chunkSize uint64) (data []byte) { func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) { - if chunkSize < memCacheSizeLimit { - if data = c.memCache.GetChunk(fileId); data != nil { - return data - } + data = c.memCache.GetChunk(fileId) + if len(data) != 0 && len(data) >= int(chunkSize) { + return data } fid, err := needle.ParseFileIdFromString(fileId) @@ -58,21 +57,9 @@ func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) { return nil } - if chunkSize < onDiskCacheSizeLimit0 { - data = c.diskCaches[0].getChunk(fid.Key) - if len(data) >= int(chunkSize) { - return data - } - } - if chunkSize < onDiskCacheSizeLimit1 { - data = c.diskCaches[1].getChunk(fid.Key) - if len(data) >= int(chunkSize) { - return data - } - } - { - data = c.diskCaches[2].getChunk(fid.Key) - if len(data) >= int(chunkSize) { + for _, diskCache := range c.diskCaches { + data := diskCache.getChunk(fid.Key) + if len(data) != 0 && len(data) >= int(chunkSize) { return data } } |
