|
|
|
@ -78,10 +78,10 @@ type cacheObjects struct { |
|
|
|
|
cacheStats *CacheStats |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
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) |
|
|
|
|
CopyObjectFn func(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error) |
|
|
|
|
InnerGetObjectInfoFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error) |
|
|
|
|
InnerDeleteObjectFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error) |
|
|
|
|
InnerPutObjectFn func(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error) |
|
|
|
|
InnerCopyObjectFn 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 { |
|
|
|
@ -120,7 +120,7 @@ func (c *cacheObjects) updateMetadataIfChanged(ctx context.Context, dcache *disk |
|
|
|
|
|
|
|
|
|
// DeleteObject clears cache entry if backend delete operation succeeds
|
|
|
|
|
func (c *cacheObjects) DeleteObject(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error) { |
|
|
|
|
if objInfo, err = c.DeleteObjectFn(ctx, bucket, object, opts); err != nil { |
|
|
|
|
if objInfo, err = c.InnerDeleteObjectFn(ctx, bucket, object, opts); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if c.isCacheExclude(bucket, object) || c.skipCache() { |
|
|
|
@ -231,7 +231,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
objInfo, err := c.GetObjectInfoFn(ctx, bucket, object, opts) |
|
|
|
|
objInfo, err := c.InnerGetObjectInfoFn(ctx, bucket, object, opts) |
|
|
|
|
if backendDownError(err) && cacheErr == nil { |
|
|
|
|
c.incCacheStats(cacheObjSize) |
|
|
|
|
return cacheReader, nil |
|
|
|
@ -351,7 +351,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string |
|
|
|
|
|
|
|
|
|
// Returns ObjectInfo from cache if available.
|
|
|
|
|
func (c *cacheObjects) GetObjectInfo(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) { |
|
|
|
|
getObjectInfoFn := c.GetObjectInfoFn |
|
|
|
|
getObjectInfoFn := c.InnerGetObjectInfoFn |
|
|
|
|
|
|
|
|
|
if c.isCacheExclude(bucket, object) || c.skipCache() { |
|
|
|
|
return getObjectInfoFn(ctx, bucket, object, opts) |
|
|
|
@ -409,7 +409,7 @@ func (c *cacheObjects) GetObjectInfo(ctx context.Context, bucket, object string, |
|
|
|
|
|
|
|
|
|
// CopyObject reverts to backend after evicting any stale cache entries
|
|
|
|
|
func (c *cacheObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBucket, dstObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error) { |
|
|
|
|
copyObjectFn := c.CopyObjectFn |
|
|
|
|
copyObjectFn := c.InnerCopyObjectFn |
|
|
|
|
if c.isCacheExclude(srcBucket, srcObject) || c.skipCache() { |
|
|
|
|
return copyObjectFn(ctx, srcBucket, srcObject, dstBucket, dstObject, srcInfo, srcOpts, dstOpts) |
|
|
|
|
} |
|
|
|
@ -596,7 +596,7 @@ func (c *cacheObjects) migrateCacheFromV1toV2(ctx context.Context) { |
|
|
|
|
|
|
|
|
|
// PutObject - caches the uploaded object for single Put operations
|
|
|
|
|
func (c *cacheObjects) PutObject(ctx context.Context, bucket, object string, r *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error) { |
|
|
|
|
putObjectFn := c.PutObjectFn |
|
|
|
|
putObjectFn := c.InnerPutObjectFn |
|
|
|
|
dcache, err := c.getCacheToLoc(ctx, bucket, object) |
|
|
|
|
if err != nil { |
|
|
|
|
// disk cache could not be located,execute backend call.
|
|
|
|
@ -668,19 +668,19 @@ func newServerCacheObjects(ctx context.Context, config cache.Config) (CacheObjec |
|
|
|
|
migrating: migrateSw, |
|
|
|
|
migMutex: sync.Mutex{}, |
|
|
|
|
cacheStats: newCacheStats(), |
|
|
|
|
GetObjectInfoFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) { |
|
|
|
|
InnerGetObjectInfoFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) { |
|
|
|
|
return newObjectLayerFn().GetObjectInfo(ctx, bucket, object, opts) |
|
|
|
|
}, |
|
|
|
|
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) |
|
|
|
|
}, |
|
|
|
|
DeleteObjectFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) { |
|
|
|
|
InnerDeleteObjectFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) { |
|
|
|
|
return newObjectLayerFn().DeleteObject(ctx, bucket, object, opts) |
|
|
|
|
}, |
|
|
|
|
PutObjectFn: func(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error) { |
|
|
|
|
InnerPutObjectFn: func(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error) { |
|
|
|
|
return newObjectLayerFn().PutObject(ctx, bucket, object, data, opts) |
|
|
|
|
}, |
|
|
|
|
CopyObjectFn: func(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error) { |
|
|
|
|
InnerCopyObjectFn: func(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error) { |
|
|
|
|
return newObjectLayerFn().CopyObject(ctx, srcBucket, srcObject, destBucket, destObject, srcInfo, srcOpts, dstOpts) |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|