@VisibleForTesting PerformanceCachingGoogleCloudStorage( GoogleCloudStorage delegate, PerformanceCachingGoogleCloudStorageOptions options, PrefixMappedItemCache cache) { super(delegate); this.inferImplicitDirectoriesEnabled = options.isInferImplicitDirectoriesEnabled(); this.listCachingEnabled = options.isListCachingEnabled(); this.cache = cache; }
/** * Creates a wrapper around a GoogleCloudStorage instance, caching calls that create, update, * remove, and query for GoogleCloudStorageItemInfo. Those cached copies are returned when * requesting data through {@link GoogleCloudStorage#getItemInfo(StorageResourceId)} and {@link * GoogleCloudStorage#getItemInfo(StorageResourceId)}. This provides faster access to recently * queried data in the scope of this instance. Because the data is cached, modifications made * outside of this instance may not be immediately reflected. * * @param delegate the {@link GoogleCloudStorage} instance to wrap and delegate calls to. * @param options the options to configure this cache with. */ public PerformanceCachingGoogleCloudStorage( GoogleCloudStorage delegate, PerformanceCachingGoogleCloudStorageOptions options) { super(delegate); this.inferImplicitDirectoriesEnabled = options.isInferImplicitDirectoriesEnabled(); this.listCachingEnabled = options.isListCachingEnabled(); // Create the cache configuration. PrefixMappedItemCache.Config config = new PrefixMappedItemCache.Config(); config.setMaxEntryAgeMillis(options.getMaxEntryAgeMillis()); this.cache = new PrefixMappedItemCache(config); }