mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-23 00:53:36 +08:00
since we already know the chunk size, no need to iterate
This commit is contained in:
@@ -46,9 +46,11 @@ func (c *ChunkCache) GetChunk(fileId string, chunkSize uint64) (data []byte) {
|
||||
|
||||
func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) {
|
||||
|
||||
data = c.memCache.GetChunk(fileId)
|
||||
if len(data) != 0 && len(data) >= int(chunkSize) {
|
||||
return data
|
||||
if chunkSize < memCacheSizeLimit {
|
||||
data = c.memCache.GetChunk(fileId)
|
||||
if len(data) >= int(chunkSize) {
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
fid, err := needle.ParseFileIdFromString(fileId)
|
||||
@@ -57,9 +59,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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user