public class ResourceCacheImpl extends Object implements ResourceCacheInterface
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PRODUCT_CACHE_DIRECTORY
Default location for product-cache directory,
|
Constructor and Description |
---|
ResourceCacheImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addPendingCacheEntry(ReliableResource reliableResource)
Adds resource to list of resources in process of being cached.
|
boolean |
containsValid(String key,
Metacard latestMetacard)
States whether an item is in the cache or not.
|
long |
getCacheDirMaxSizeMegabytes() |
org.osgi.framework.BundleContext |
getContext() |
String |
getProductCacheDirectory() |
Resource |
getValid(String key,
Metacard latestMetacard)
Gets a valid resource from the cache.
|
String |
getXmlConfigFilename() |
boolean |
isPending(String key)
Returns true if resource with specified cache key is already in the process of being cached.
|
void |
put(ReliableResource reliableResource)
Called by ReliableResourceDownloadManager when resource has completed being cached to disk and
is ready to be added to the cache map.
|
void |
removePendingCacheEntry(String cacheKey)
Removes resource from list of pending resources being added to cache.
|
void |
setCache(com.hazelcast.core.HazelcastInstance instance)
Called after all parameters are set
|
void |
setCacheDirMaxSizeMegabytes(long cacheDirMaxSizeMegabytes) |
void |
setContext(org.osgi.framework.BundleContext context) |
void |
setProductCacheDirectory(String productCacheDirectory) |
void |
setupCache() |
void |
setXmlConfigFilename(String xmlConfigFilename) |
void |
teardownCache() |
protected boolean |
validateCacheEntry(ReliableResource cachedResource,
Metacard latestMetacard)
Compares the
Metacard in a ReliableResource pulled from cache with a Metacard
obtained directly from the Catalog to ensure they are the same. |
public static final String DEFAULT_PRODUCT_CACHE_DIRECTORY
public void setCache(com.hazelcast.core.HazelcastInstance instance)
public void setupCache()
public void teardownCache()
public long getCacheDirMaxSizeMegabytes()
public void setCacheDirMaxSizeMegabytes(long cacheDirMaxSizeMegabytes)
public String getProductCacheDirectory()
public void setProductCacheDirectory(String productCacheDirectory)
public org.osgi.framework.BundleContext getContext()
public void setContext(org.osgi.framework.BundleContext context)
public String getXmlConfigFilename()
public void setXmlConfigFilename(String xmlConfigFilename)
public boolean isPending(String key)
isPending
in interface ResourceCacheInterface
key
- public void put(ReliableResource reliableResource)
put
in interface ResourceCacheInterface
reliableResource
- the resource to add to the cache mappublic void removePendingCacheEntry(String cacheKey)
ResourceCacheInterface
removePendingCacheEntry
in interface ResourceCacheInterface
public void addPendingCacheEntry(ReliableResource reliableResource)
ResourceCacheInterface
addPendingCacheEntry
in interface ResourceCacheInterface
public Resource getValid(String key, Metacard latestMetacard)
ResourceCacheInterface
A valid resource is one where the corresponding Metacard in the Catalog has not changed since its resource was cached.
getValid
in interface ResourceCacheInterface
key
- null
if not found.public boolean containsValid(String key, Metacard latestMetacard)
containsValid
in interface ResourceCacheInterface
key
- true
if items exists in cache.protected boolean validateCacheEntry(ReliableResource cachedResource, Metacard latestMetacard)
Metacard
in a ReliableResource
pulled from cache with a Metacard
obtained directly from the Catalog to ensure they are the same. Typically used to determine if
the cache entry is out-of-date based on the Catalog having an updated Metacard.cachedResource
- latestMetacard
- This work is licensed under a Creative Commons Attribution 4.0 International License.