mirror of
https://github.com/minio/minio.git
synced 2025-04-23 20:05:55 -04:00
parent
eb95353cb1
commit
0994ed9783
@ -77,11 +77,11 @@ type cacheObjects struct {
|
|||||||
// Cache stats
|
// Cache stats
|
||||||
cacheStats *CacheStats
|
cacheStats *CacheStats
|
||||||
|
|
||||||
GetObjectNInfoFn func(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error)
|
InnerGetObjectNInfoFn func(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error)
|
||||||
GetObjectInfoFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
GetObjectInfoFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
||||||
DeleteObjectFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
DeleteObjectFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
||||||
PutObjectFn func(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
PutObjectFn func(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
||||||
CopyObjectFn func(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error)
|
CopyObjectFn func(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cacheObjects) incHitsToMeta(ctx context.Context, dcache *diskCache, bucket, object string, size int64, eTag string, rs *HTTPRangeSpec) error {
|
func (c *cacheObjects) incHitsToMeta(ctx context.Context, dcache *diskCache, bucket, object string, size int64, eTag string, rs *HTTPRangeSpec) error {
|
||||||
@ -188,14 +188,14 @@ func (c *cacheObjects) incCacheStats(size int64) {
|
|||||||
|
|
||||||
func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) {
|
func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) {
|
||||||
if c.isCacheExclude(bucket, object) || c.skipCache() {
|
if c.isCacheExclude(bucket, object) || c.skipCache() {
|
||||||
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
return c.InnerGetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
||||||
}
|
}
|
||||||
var cc *cacheControl
|
var cc *cacheControl
|
||||||
var cacheObjSize int64
|
var cacheObjSize int64
|
||||||
// fetch diskCache if object is currently cached or nearest available cache drive
|
// fetch diskCache if object is currently cached or nearest available cache drive
|
||||||
dcache, err := c.getCacheToLoc(ctx, bucket, object)
|
dcache, err := c.getCacheToLoc(ctx, bucket, object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
return c.InnerGetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheReader, numCacheHits, cacheErr := dcache.Get(ctx, bucket, object, rs, h, opts)
|
cacheReader, numCacheHits, cacheErr := dcache.Get(ctx, bucket, object, rs, h, opts)
|
||||||
@ -224,7 +224,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string
|
|||||||
if cc != nil && cc.noStore {
|
if cc != nil && cc.noStore {
|
||||||
cacheReader.Close()
|
cacheReader.Close()
|
||||||
c.cacheStats.incMiss()
|
c.cacheStats.incMiss()
|
||||||
bReader, err := c.GetObjectNInfo(ctx, bucket, object, rs, h, lockType, opts)
|
bReader, err := c.InnerGetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
||||||
bReader.ObjInfo.CacheLookupStatus = CacheHit
|
bReader.ObjInfo.CacheLookupStatus = CacheHit
|
||||||
bReader.ObjInfo.CacheStatus = CacheMiss
|
bReader.ObjInfo.CacheStatus = CacheMiss
|
||||||
return bReader, err
|
return bReader, err
|
||||||
@ -255,7 +255,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string
|
|||||||
cacheReader.Close()
|
cacheReader.Close()
|
||||||
}
|
}
|
||||||
c.cacheStats.incMiss()
|
c.cacheStats.incMiss()
|
||||||
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
return c.InnerGetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
||||||
}
|
}
|
||||||
// skip cache for objects with locks
|
// skip cache for objects with locks
|
||||||
objRetention := objectlock.GetObjectRetentionMeta(objInfo.UserDefined)
|
objRetention := objectlock.GetObjectRetentionMeta(objInfo.UserDefined)
|
||||||
@ -265,7 +265,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string
|
|||||||
cacheReader.Close()
|
cacheReader.Close()
|
||||||
}
|
}
|
||||||
c.cacheStats.incMiss()
|
c.cacheStats.incMiss()
|
||||||
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
return c.InnerGetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
||||||
}
|
}
|
||||||
if cacheErr == nil {
|
if cacheErr == nil {
|
||||||
// if ETag matches for stale cache entry, serve from cache
|
// if ETag matches for stale cache entry, serve from cache
|
||||||
@ -283,7 +283,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string
|
|||||||
// Reaching here implies cache miss
|
// Reaching here implies cache miss
|
||||||
c.cacheStats.incMiss()
|
c.cacheStats.incMiss()
|
||||||
|
|
||||||
bkReader, bkErr := c.GetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
bkReader, bkErr := c.InnerGetObjectNInfoFn(ctx, bucket, object, rs, h, lockType, opts)
|
||||||
|
|
||||||
if bkErr != nil {
|
if bkErr != nil {
|
||||||
return bkReader, bkErr
|
return bkReader, bkErr
|
||||||
@ -312,7 +312,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string
|
|||||||
rs = nil
|
rs = nil
|
||||||
}
|
}
|
||||||
// fill cache in the background for range GET requests
|
// fill cache in the background for range GET requests
|
||||||
bReader, bErr := c.GetObjectNInfoFn(GlobalContext, bucket, object, rs, h, lockType, opts)
|
bReader, bErr := c.InnerGetObjectNInfoFn(GlobalContext, bucket, object, rs, h, lockType, opts)
|
||||||
if bErr != nil {
|
if bErr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ func (c *cacheObjects) PutObject(ctx context.Context, bucket, object string, r *
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
go func() {
|
go func() {
|
||||||
// fill cache in the background
|
// fill cache in the background
|
||||||
bReader, bErr := c.GetObjectNInfoFn(GlobalContext, bucket, object, nil, http.Header{}, readLock, ObjectOptions{})
|
bReader, bErr := c.InnerGetObjectNInfoFn(GlobalContext, bucket, object, nil, http.Header{}, readLock, ObjectOptions{})
|
||||||
if bErr != nil {
|
if bErr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ func newServerCacheObjects(ctx context.Context, config cache.Config) (CacheObjec
|
|||||||
GetObjectInfoFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) {
|
GetObjectInfoFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) {
|
||||||
return newObjectLayerFn().GetObjectInfo(ctx, bucket, object, opts)
|
return newObjectLayerFn().GetObjectInfo(ctx, bucket, object, opts)
|
||||||
},
|
},
|
||||||
GetObjectNInfoFn: func(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) {
|
InnerGetObjectNInfoFn: func(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) {
|
||||||
return newObjectLayerFn().GetObjectNInfo(ctx, bucket, object, rs, h, lockType, opts)
|
return newObjectLayerFn().GetObjectNInfo(ctx, bucket, object, rs, h, lockType, opts)
|
||||||
},
|
},
|
||||||
DeleteObjectFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) {
|
DeleteObjectFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user