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
This implementation caches every file using
LRUMap
.
The default constructor uses a LRU size of 100 per filesystem.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear
(FileSystem filesystem) Purges the entries corresponding to the FileSystem.void
close()
Closes the provider.getFile
(FileSystem filesystem, FileName name) Retrieves a FileObject from the cache by name.protected Map<FileName,
FileObject> getOrCreateFilesystemCache
(FileSystem filesystem) void
putFile
(FileObject file) Adds a FileObject to the cache.boolean
putFileIfAbsent
(FileObject file) Adds a FileObject to the cache if it isn't already present.void
removeFile
(FileSystem filesystem, FileName name) Removes a file from cache.void
touchFile
(FileObject file) Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, init, setContext, setLogger
-
Constructor Details
-
LRUFilesCache
public LRUFilesCache()Default constructor. Uses a LRU size of 100 per filesystem. -
LRUFilesCache
Set the desired LRU size.- Parameters:
lruSize
- the LRU size
-
-
Method Details
-
putFile
Description copied from interface:FilesCache
Adds a FileObject to the cache.- Parameters:
file
- the file
-
putFileIfAbsent
Description copied from interface:FilesCache
Adds 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
Description copied from interface:FilesCache
Retrieves a FileObject from the cache by name.- Parameters:
filesystem
- The FileSystem.name
- the name- Returns:
- the file object or null if file is not cached
-
clear
Description copied from interface:FilesCache
Purges the entries corresponding to the FileSystem.- Parameters:
filesystem
- The FileSystem.
-
getOrCreateFilesystemCache
-
close
Description copied from class:AbstractVfsComponent
Closes the provider. This implementation does nothing.- Specified by:
close
in interfaceFilesCache
- Specified by:
close
in interfaceVfsComponent
- Overrides:
close
in classAbstractVfsComponent
-
removeFile
Description copied from interface:FilesCache
Removes a file from cache.- Parameters:
filesystem
- filesystemname
- filename
-
touchFile
- Overrides:
touchFile
in classAbstractFilesCache
-