1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-06-29 13:50:10 +02:00

a little bit more efficient

This commit is contained in:
Chris Lu 2020-06-26 10:02:37 -07:00
parent 212b6e7d42
commit 3dbd51c3c2

View file

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