diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-06-26 10:02:37 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-06-26 10:02:37 -0700 |
| commit | 3dbd51c3c2b2badc5360f803e62da818d3e6c23f (patch) | |
| tree | ba2fe0ca71e022722608197b48547e0e13c87e4b | |
| parent | 212b6e7d4202d59ef82bdaa6ff753e9e402a2d64 (diff) | |
| download | seaweedfs-3dbd51c3c2b2badc5360f803e62da818d3e6c23f.tar.xz seaweedfs-3dbd51c3c2b2badc5360f803e62da818d3e6c23f.zip | |
a little bit more efficient
| -rw-r--r-- | weed/util/chunk_cache/chunk_cache.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.go index ca26e1f77..325253837 100644 --- a/weed/util/chunk_cache/chunk_cache.go +++ b/weed/util/chunk_cache/chunk_cache.go @@ -58,9 +58,21 @@ func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) { return nil } - for _, diskCache := range c.diskCaches { - data := diskCache.getChunk(fid.Key) - if len(data) != 0 && len(data) >= int(chunkSize) { + 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) { return data } } |
