diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index 9de9581e1..a1437b4c9 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -38,8 +38,7 @@ import ( ) const ( - // disk cache needs to have cacheSizeMultiplier * object size space free for a cache entry to be created. - cacheSizeMultiplier = 100 + // disk cache needs to have object size space free for a cache entry to be created. cacheTrashDir = "trash" cacheCleanupInterval = 10 // in minutes ) @@ -231,8 +230,7 @@ func (c cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string, // We don't cache partial objects. return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock, opts) } - if !dcache.diskAvailable(objInfo.Size * cacheSizeMultiplier) { - // cache only objects < 1/100th of disk capacity + if !dcache.diskAvailable(objInfo.Size) { return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock, opts) } @@ -308,8 +306,7 @@ func (c cacheObjects) GetObject(ctx context.Context, bucket, object string, star // We don't cache partial objects. return GetObjectFn(ctx, bucket, object, startOffset, length, writer, etag, opts) } - if !dcache.diskAvailable(objInfo.Size * cacheSizeMultiplier) { - // cache only objects < 1/100th of disk capacity + if !dcache.diskAvailable(objInfo.Size) { return GetObjectFn(ctx, bucket, object, startOffset, length, writer, etag, opts) } // Initialize pipe. @@ -656,7 +653,7 @@ func (c cacheObjects) PutObject(ctx context.Context, bucket, object string, r *h size := r.Size() // fetch from backend if there is no space on cache drive - if !dcache.diskAvailable(size * cacheSizeMultiplier) { + if !dcache.diskAvailable(size) { return putObjectFn(ctx, bucket, object, r, metadata, opts) } // fetch from backend if cache exclude pattern or cache-control @@ -748,9 +745,9 @@ func (c cacheObjects) PutObjectPart(ctx context.Context, bucket, object, uploadI return putObjectPartFn(ctx, bucket, object, uploadID, partID, data, opts) } - // make sure cache has at least cacheSizeMultiplier * size available + // make sure cache has at least size space available size := data.Size() - if !dcache.diskAvailable(size * cacheSizeMultiplier) { + if !dcache.diskAvailable(size) { select { case dcache.purgeChan <- struct{}{}: default: diff --git a/docs/disk-caching/DESIGN.md b/docs/disk-caching/DESIGN.md index 80ecfeaa6..c83aa2ade 100644 --- a/docs/disk-caching/DESIGN.md +++ b/docs/disk-caching/DESIGN.md @@ -31,7 +31,7 @@ minio server -h - The cache drives are required to be a filesystem mount point with [`atime`](http://kerolasa.github.io/filetimes.html) support to be enabled on the drive. Alternatively writable directories with atime support can be specified in MINIO_CACHE_DRIVES - Expiration of each cached entry takes user provided expiry as a hint, and defaults to 90 days if not provided. - Garbage collection sweep of the expired cache entries happens whenever cache usage is > 80% of drive capacity, GC continues until sufficient disk space is reclaimed. -- An object is only cached when drive has sufficient disk space, upto 100 times the size of the object. +- An object is only cached when drive has sufficient disk space. ## Behavior Disk caching caches objects for both **uploaded** and **downloaded** objects i.e