Class FileCache<T extends FileCache.Cacheable>
- java.lang.Object
-
- com.dtolabs.rundeck.core.utils.cache.FileCache<T>
-
public class FileCache<T extends FileCache.Cacheable> extends java.lang.ObjectFileCache stores items associated with a file and expires them if the file is removed or modified. TheFileCache.ItemCreatorinterface is used to create cacheable items
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFileCache.CacheableCacheable item for FileCache.static interfaceFileCache.Expiration<T>Determines whether a cached item has expiredstatic interfaceFileCache.ExpireableAllows expire method to be called for a cached item when it is expired from the cachestatic interfaceFileCache.ItemCreator<T>Creates an item to store in the cachestatic classFileCache.LastModifiedExpiration<T>Expires items if the lastModified of the file is greater than the cached time for the item.static interfaceFileCache.MemoFilestatic classFileCache.MemoFileImpl
-
Constructor Summary
Constructors Constructor Description FileCache()Use theFileCache.LastModifiedExpirationexpiration policy by default.FileCache(FileCache.Expiration<T> expiration)Use a specific expiration policy
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<java.io.File>cachedFiles()Tget(java.io.File file, FileCache.ItemCreator<T> creator)Get entry for a file, and use the creator if necessary to create it.static java.lang.StringmemoFile(java.io.File file)static FileCache.MemoFilememoize(java.io.File file)voidremove(java.io.File file)Remove entry for a file.
-
-
-
Constructor Detail
-
FileCache
public FileCache()
Use theFileCache.LastModifiedExpirationexpiration policy by default.
-
FileCache
public FileCache(FileCache.Expiration<T> expiration)
Use a specific expiration policy- Parameters:
expiration- policy
-
-
Method Detail
-
remove
public void remove(java.io.File file)
Remove entry for a file.- Parameters:
file- file
-
cachedFiles
public java.util.Set<java.io.File> cachedFiles()
-
memoFile
public static java.lang.String memoFile(java.io.File file)
-
memoize
public static FileCache.MemoFile memoize(java.io.File file)
-
get
public T get(java.io.File file, FileCache.ItemCreator<T> creator)
Get entry for a file, and use the creator if necessary to create it. The creator will be called if the cache is out of date for the file. If the created item is equals to any existing cached item for the file then the old item will not be replaced. Otherwise, if the old item isFileCache.Expireablethen theFileCache.Expireable.expire()method will be called on it.- Parameters:
file- the iflecreator- the item creator- Returns:
- the item associated with the file, or null if none is found
-
-