public interface CachingObjectStorage
extends com.oracle.bmc.objectstorage.ObjectStorage
ObjectStorage
that caches the contents returned by
ObjectStorage.getObject(GetObjectRequest)
on disk.
Requests that result in exceptions are not cached and will be retried.
Note that the streams returned by GetObjectResponse.getInputStream()
are automatically closed once they
have been completely read. This is necessary to make clean-up as reliable as possible.
Note also that, if a stream is not not closed, the cache file will remain on disk and will not be deleted.
The cache supports "maximumWeight", and the weight is expressed in bytes. Note that the default Cache
that is used considers "maximumWeight" to be per cache section. The number of cache sections is controlled using
the "concurrencyLevel" setting. If you want to limit the overall size to X bytes, you should use
"maximumWeight=X,concurrencyLevel=1".
Cache clean-up (i.e. timed evictions) may only take place when operations happen. If you need to explicitly
clean-up, you can call cleanUp()
.Modifier and Type | Interface and Description |
---|---|
static class |
CachingObjectStorage.CachedInputStream
Input stream using a cached file.
|
static class |
CachingObjectStorage.Configuration
Configuration.
|
static class |
CachingObjectStorage.DefaultRowLockProvider |
static class |
CachingObjectStorage.DefaultUncacheablePredicate
By default, this implementation does not cache requests with if-none-match set.
|
static class |
CachingObjectStorage.DeletionRunnable |
static class |
CachingObjectStorage.GetObjectRequestCacheKey
We unfortunately need a wrapper around
GetObjectRequest , because we don't want everything to be
considered for equals and hashCode. |
static class |
CachingObjectStorage.GetObjectResponseCacheValue |
static class |
CachingObjectStorage.Handler
Implemented as proxy/invocation handler, so we don't have to add more and more methods that just
client to the inner
ObjectStorage instance. |
static class |
CachingObjectStorage.PathHolder
It seems like the JDK is doing some kind of caching or re-use of Path instances, preventing PhantomReferences
from working properly.
|
static class |
CachingObjectStorage.PathPhantomReference
This phantom reference is used to delete evicted cached files once they are not accessible anymore by the
Java application (because there are no more references held to it).
|
static class |
CachingObjectStorage.RemovalListener |
static class |
CachingObjectStorage.RowLock |
static interface |
CachingObjectStorage.RowLockProvider |
static interface |
CachingObjectStorage.UncacheablePredicate
Interface for deciding if a request cannot be cached.
|
Modifier and Type | Method and Description |
---|---|
static CachingObjectStorage |
build(CachingObjectStorage.Configuration config)
Returns a new
CachingObjectStorage client. |
static CachingObjectStorage |
build(com.oracle.bmc.objectstorage.ObjectStorage client,
com.oracle.bmc.objectstorage.transfer.DownloadConfiguration downloadConfiguration,
Path cacheDirectory,
ExecutorService downloadExecutor,
CachingObjectStorage.UncacheablePredicate uncacheablePredicate,
ConsistencyPolicy consistencyPolicy,
CacheBuilder<CachingObjectStorage.GetObjectRequestCacheKey,CachingObjectStorage.GetObjectResponseCacheValue,?> cacheBuilder,
ExecutorService deletionExecutor,
CachingObjectStorage.RowLockProvider rowLockProvider,
Runnable cacheGarbageCollection)
Returns a new
CachingObjectStorage client. |
void |
cleanUp()
Performs cache clean-up, i.e.
|
Cache.Statistics |
getCacheStatistics()
Return the statistics for the getObject cache.
|
Set<Path> |
getEvictedButNotDeleted()
Returns a read-only set of paths to files that have been evicted but not deleted yet, since they are still being
read.
|
com.oracle.bmc.objectstorage.responses.GetObjectResponse |
getObjectUncached(com.oracle.bmc.objectstorage.requests.GetObjectRequest getObjectRequest)
Get the object, circumventing the cache.
|
static CachingObjectStorage.Configuration.ConfigurationBuilder |
newConfiguration()
Returns a new configuration builder.
|
void |
prepopulateCache(com.oracle.bmc.objectstorage.requests.GetObjectRequest cacheRequest,
com.oracle.bmc.objectstorage.responses.GetObjectResponse cacheResponse)
Populates the cache at the request with the given response.
|
abortMultipartUpload, cancelWorkRequest, commitMultipartUpload, copyObject, createBucket, createMultipartUpload, createPreauthenticatedRequest, createReplicationPolicy, createRetentionRule, deleteBucket, deleteObject, deleteObjectLifecyclePolicy, deletePreauthenticatedRequest, deleteReplicationPolicy, deleteRetentionRule, getBucket, getEndpoint, getNamespace, getNamespaceMetadata, getObject, getObjectLifecyclePolicy, getPaginators, getPreauthenticatedRequest, getReplicationPolicy, getRetentionRule, getWaiters, getWorkRequest, headBucket, headObject, listBuckets, listMultipartUploadParts, listMultipartUploads, listObjects, listObjectVersions, listPreauthenticatedRequests, listReplicationPolicies, listReplicationSources, listRetentionRules, listWorkRequestErrors, listWorkRequestLogs, listWorkRequests, makeBucketWritable, putObject, putObjectLifecyclePolicy, reencryptBucket, reencryptObject, refreshClient, renameObject, restoreObjects, setEndpoint, setRegion, setRegion, updateBucket, updateNamespaceMetadata, updateObjectStorageTier, updateRetentionRule, uploadPart, useRealmSpecificEndpointTemplate
close
static CachingObjectStorage.Configuration.ConfigurationBuilder newConfiguration()
static CachingObjectStorage build(CachingObjectStorage.Configuration config)
CachingObjectStorage
client.config
- the configuration, which can be created with the newConfiguration()
method.CachingObjectStorage
clientstatic CachingObjectStorage build(com.oracle.bmc.objectstorage.ObjectStorage client, com.oracle.bmc.objectstorage.transfer.DownloadConfiguration downloadConfiguration, Path cacheDirectory, ExecutorService downloadExecutor, CachingObjectStorage.UncacheablePredicate uncacheablePredicate, ConsistencyPolicy consistencyPolicy, CacheBuilder<CachingObjectStorage.GetObjectRequestCacheKey,CachingObjectStorage.GetObjectResponseCacheValue,?> cacheBuilder, ExecutorService deletionExecutor, CachingObjectStorage.RowLockProvider rowLockProvider, Runnable cacheGarbageCollection)
CachingObjectStorage
client.client
- the actual ObjectStorage
that the cached client delegates todownloadConfiguration
- the DownloadConfiguration
that the cached client will use for downloadingcacheDirectory
- directory where items are cacheddownloadExecutor
- executor for providing the threads in which objects will be downloadeduncacheablePredicate
- predicate that decides if a request cannot be cachedconsistencyPolicy
- controls eviction of conflicting itemscacheBuilder
- cache builder that will actually create the cachedeletionExecutor
- for creating a thread that deletes evicted files after they are not being read anymorerowLockProvider
- provider for row lockscacheGarbageCollection
- runnable to be executed when there is a cache updateCachingObjectStorage
clientcom.oracle.bmc.objectstorage.responses.GetObjectResponse getObjectUncached(com.oracle.bmc.objectstorage.requests.GetObjectRequest getObjectRequest)
getObjectRequest
- requestvoid cleanUp()
ObjectStorage.getObject(GetObjectRequest)
operations are performed, but in absence of such
activity, this method can be used to trigger clean-up on-demand.Set<Path> getEvictedButNotDeleted()
Cache.Statistics getCacheStatistics()
void prepopulateCache(com.oracle.bmc.objectstorage.requests.GetObjectRequest cacheRequest, com.oracle.bmc.objectstorage.responses.GetObjectResponse cacheResponse)
cacheRequest
- request entry to fill.cacheResponse
- content to be put at the cache entry.Copyright © 2016–2023. All rights reserved.