Class FileCache
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringDOWNLOAD_DIR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FileCachebuild(long maxSize, File root, org.apache.jackrabbit.guava.common.cache.CacheLoader<String,InputStream> loader, @Nullable ExecutorService executor)voidclose()booleancontainsKey(String key)Fileget(String key)longgetEntryCount()Get the current entry count (number of files).@Nullable FilegetIfPresent(Object key)@Nullable FilegetIfPresent(String key)Retrieves the file handle from the cache if present and null otherwise.DataStoreCacheStatsMBeangetStats()voidinvalidate(Object key)voidput(String key, File file)Puts the given key and file into the cache.voidsetMaxEntryCount(long maxEntryCount)Set the maximum number of files.
-
-
-
Field Detail
-
DOWNLOAD_DIR
protected static final String DOWNLOAD_DIR
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public void put(String key, File file)
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
public boolean containsKey(String key)
-
getIfPresent
@Nullable public @Nullable File getIfPresent(String key)
Retrieves the file handle from the cache if present and null otherwise.- Parameters:
key- of the file to retrieve- Returns:
- File handle if available
-
get
public File get(String key) throws IOException
- Throws:
IOException
-
invalidate
public void invalidate(Object key)
-
getStats
public DataStoreCacheStatsMBean getStats()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-