Clear cache if reverting to backend (#8637)

Clear cached entry before reverting to backend for
encrypted objects or those under retention to avoid
stale objects remaining in cache.
This commit is contained in:
poornas 2019-12-12 15:11:27 -08:00 committed by Harshavardhana
parent ca62ac65d4
commit 80558e839d

View File

@ -585,12 +585,14 @@ func (c *cacheObjects) PutObject(ctx context.Context, bucket, object string, r *
return putObjectFn(ctx, bucket, object, r, opts)
}
if opts.ServerSideEncryption != nil {
dcache.Delete(ctx, bucket, object)
return putObjectFn(ctx, bucket, object, r, opts)
}
// skip cache for objects with locks
objRetention := getObjectRetentionMeta(opts.UserDefined)
if objRetention.Mode == Governance || objRetention.Mode == Compliance {
dcache.Delete(ctx, bucket, object)
return putObjectFn(ctx, bucket, object, r, opts)
}