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.Object
FileCache stores items associated with a file and expires them if the file is removed or modified. TheFileCache.ItemCreator
interface is used to create cacheable items
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FileCache.Cacheable
Cacheable item for FileCache.static interface
FileCache.Expiration<T>
Determines whether a cached item has expiredstatic interface
FileCache.Expireable
Allows expire method to be called for a cached item when it is expired from the cachestatic interface
FileCache.ItemCreator<T>
Creates an item to store in the cachestatic class
FileCache.LastModifiedExpiration<T>
Expires items if the lastModified of the file is greater than the cached time for the item.static interface
FileCache.MemoFile
static class
FileCache.MemoFileImpl
-
Constructor Summary
Constructors Constructor Description FileCache()
Use theFileCache.LastModifiedExpiration
expiration 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()
T
get(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.String
memoFile(java.io.File file)
static FileCache.MemoFile
memoize(java.io.File file)
void
remove(java.io.File file)
Remove entry for a file.
-
-
-
Constructor Detail
-
FileCache
public FileCache()
Use theFileCache.LastModifiedExpiration
expiration 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.Expireable
then 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
-
-