Class FileCache
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.jackrabbit.guava.common.cache.Cache<String,
File>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.jackrabbit.guava.common.cache.AbstractCache
org.apache.jackrabbit.guava.common.cache.AbstractCache.SimpleStatsCounter, org.apache.jackrabbit.guava.common.cache.AbstractCache.StatsCounter
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic FileCache
build
(long maxSize, File root, org.apache.jackrabbit.guava.common.cache.CacheLoader<String, InputStream> loader, @Nullable ExecutorService executor) void
close()
boolean
containsKey
(String key) long
Get the current entry count (number of files).@Nullable File
getIfPresent
(Object key) @Nullable File
getIfPresent
(String key) Retrieves the file handle from the cache if present and null otherwise.getStats()
void
invalidate
(Object key) void
Puts the given key and file into the cache.void
setMaxEntryCount
(long maxEntryCount) Set the maximum number of files.Methods inherited from class org.apache.jackrabbit.guava.common.cache.AbstractCache
asMap, cleanUp, get, getAllPresent, invalidateAll, invalidateAll, putAll, size, stats
-
Field Details
-
DOWNLOAD_DIR
- See Also:
-
-
Method Details
-
setMaxEntryCount
public void setMaxEntryCount(long maxEntryCount) Set the maximum number of files. -
getEntryCount
public long getEntryCount()Get the current entry count (number of files). -
build
public static FileCache build(long maxSize, File root, org.apache.jackrabbit.guava.common.cache.CacheLoader<String, InputStream> loader, @Nullable @Nullable ExecutorService executor) -
put
Puts the given key and file into the cache. The file is moved to the cache. So, the original file won't be available after this operation. It can be retrieved usinggetIfPresent(String)
. -
containsKey
-
getIfPresent
Retrieves the file handle from the cache if present and null otherwise.- Parameters:
key
- of the file to retrieve- Returns:
- File handle if available
-
getIfPresent
-
get
- Throws:
IOException
-
invalidate
-
getStats
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-