mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
objcache: Return io.ReaderAt to avoid Seeking and Reading. (#3735)
This commit is contained in:
@@ -217,7 +217,7 @@ func (c *Cache) Create(key string, size int64) (w io.WriteCloser, err error) {
|
||||
// returns an error ErrNotFoundInCache, if the key does not exist.
|
||||
// Returns ErrKeyNotFoundInCache if entry's lastAccessedTime is older
|
||||
// than objModTime.
|
||||
func (c *Cache) Open(key string, objModTime time.Time) (io.ReadSeeker, error) {
|
||||
func (c *Cache) Open(key string, objModTime time.Time) (io.ReaderAt, error) {
|
||||
// Entry exists, return the readable buffer.
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
|
||||
@@ -20,7 +20,6 @@ package objcache
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -173,7 +172,8 @@ func TestObjCache(t *testing.T) {
|
||||
t.Errorf("Test case 4 expected to pass, failed instead %s", err)
|
||||
}
|
||||
// Reads everything stored for key "test".
|
||||
cbytes, err := ioutil.ReadAll(r)
|
||||
cbytes := make([]byte, 5)
|
||||
_, err = r.ReadAt(cbytes, 0)
|
||||
if err != nil {
|
||||
t.Errorf("Test case 4 expected to pass, failed instead %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user