Package org.apache.commons.vfs2.cache
Class LRUFilesCache
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractVfsComponent
-
- org.apache.commons.vfs2.cache.AbstractFilesCache
-
- org.apache.commons.vfs2.cache.LRUFilesCache
-
- All Implemented Interfaces:
FilesCache,VfsComponent
public class LRUFilesCache extends AbstractFilesCache
This implementation caches every file usingLRUMap.The default constructor uses a LRU size of 100 per filesystem.
-
-
Constructor Summary
Constructors Constructor Description LRUFilesCache()Default constructor.LRUFilesCache(int lruSize)Set the desired LRU size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(FileSystem filesystem)Purges the entries corresponding to the FileSystem.voidclose()Closes the provider.FileObjectgetFile(FileSystem filesystem, FileName name)Retrieves a FileObject from the cache by name.protected java.util.Map<FileName,FileObject>getOrCreateFilesystemCache(FileSystem filesystem)voidputFile(FileObject file)Adds a FileObject to the cache.booleanputFileIfAbsent(FileObject file)Adds a FileObject to the cache if it isn't already present.voidremoveFile(FileSystem filesystem, FileName name)Removes a file from cache.voidtouchFile(FileObject file)-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, init, setContext, setLogger
-
-
-
-
Method Detail
-
putFile
public void putFile(FileObject file)
Description copied from interface:FilesCacheAdds a FileObject to the cache.- Parameters:
file- the file
-
putFileIfAbsent
public boolean putFileIfAbsent(FileObject file)
Description copied from interface:FilesCacheAdds a FileObject to the cache if it isn't already present.- Parameters:
file- the file- Returns:
- true if the file was stored, false otherwise.
-
getFile
public FileObject getFile(FileSystem filesystem, FileName name)
Description copied from interface:FilesCacheRetrieves a FileObject from the cache by name.- Parameters:
filesystem- The FileSystem.name- the name- Returns:
- the fileobject or null if file is not cached
-
clear
public void clear(FileSystem filesystem)
Description copied from interface:FilesCachePurges the entries corresponding to the FileSystem.- Parameters:
filesystem- The FileSystem.
-
getOrCreateFilesystemCache
protected java.util.Map<FileName,FileObject> getOrCreateFilesystemCache(FileSystem filesystem)
-
close
public void close()
Description copied from class:AbstractVfsComponentCloses the provider. This implementation does nothing.- Specified by:
closein interfaceFilesCache- Specified by:
closein interfaceVfsComponent- Overrides:
closein classAbstractVfsComponent
-
removeFile
public void removeFile(FileSystem filesystem, FileName name)
Description copied from interface:FilesCacheRemoves a file from cache.- Parameters:
filesystem- filesystemname- filename
-
touchFile
public void touchFile(FileObject file)
- Overrides:
touchFilein classAbstractFilesCache
-
-