Package com.google.cloud.hadoop.gcsio
Class PrefixMappedItemCache
- java.lang.Object
-
- com.google.cloud.hadoop.gcsio.PrefixMappedItemCache
-
public class PrefixMappedItemCache extends Object
A semi-persistent storage forGoogleCloudStorageItemInfothat maintains indexes based on the item's bucket and object name. In addition to cachingStorageResourceIdto item mappings, it provides options for storing groups of items under similar bucket and object name prefixes.
-
-
Constructor Summary
Constructors Constructor Description PrefixMappedItemCache(Duration maxEntryAge)Creates a newPrefixMappedItemCache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GoogleCloudStorageItemInfogetItem(StorageResourceId id)Gets the cached item associated with the given resource id.voidinvalidateAll()Invalidates all entries in the cache.voidinvalidateBucket(String bucket)Invalidates all cached items and lists associated with the given bucket.GoogleCloudStorageItemInfoputItem(GoogleCloudStorageItemInfo item)Inserts an item into the cache.GoogleCloudStorageItemInforemoveItem(StorageResourceId id)Removes the item from the cache.
-
-
-
Constructor Detail
-
PrefixMappedItemCache
public PrefixMappedItemCache(Duration maxEntryAge)
Creates a newPrefixMappedItemCache.- Parameters:
maxEntryAge- time after which entries in cache expire.
-
-
Method Detail
-
getItem
@Nullable public GoogleCloudStorageItemInfo getItem(StorageResourceId id)
Gets the cached item associated with the given resource id.- Parameters:
id- the resource id of the item to get.- Returns:
- the cached item associated with the given resource id, null if the item isn't cached or it has expired in the cache.
-
putItem
@Nullable public GoogleCloudStorageItemInfo putItem(GoogleCloudStorageItemInfo item)
Inserts an item into the cache. If an item with the same resource id is present, it is overwritten by the new item.- Parameters:
item- the item to insert. The item must have a valid resource id.- Returns:
- the overwritten item, null if no item was overwritten.
-
removeItem
@Nullable public GoogleCloudStorageItemInfo removeItem(StorageResourceId id)
Removes the item from the cache. If the item has expired, associated lists are invalidated.- Parameters:
id- the resource id of the item to remove.- Returns:
- the removed item, null if no item was removed.
-
invalidateBucket
public void invalidateBucket(String bucket)
Invalidates all cached items and lists associated with the given bucket.- Parameters:
bucket- the bucket to invalidate. This must not be null.
-
invalidateAll
public void invalidateAll()
Invalidates all entries in the cache.
-
-