Package org.apache.commons.vfs2.cache
Class SoftRefFilesCache
java.lang.Object
org.apache.commons.vfs2.provider.AbstractVfsComponent
org.apache.commons.vfs2.cache.AbstractFilesCache
org.apache.commons.vfs2.cache.SoftRefFilesCache
- All Implemented Interfaces:
FilesCache
,VfsComponent
- Direct Known Subclasses:
WeakRefFilesCache
This implementation caches every file as long as it is strongly reachable by the java vm. As soon as the vm needs
memory - every softly reachable file will be discarded.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear
(FileSystem fileSystem) Purges the entries corresponding to the FileSystem.void
close()
Closes the provider.protected Reference<FileObject>
createReference
(FileObject file, ReferenceQueue<FileObject> refqueue) getFile
(FileSystem fileSystem, FileName fileName) Retrieves a FileObject from the cache by name.protected Map<FileName,
Reference<FileObject>> getOrCreateFilesystemCache
(FileSystem fileSystem) void
putFile
(FileObject fileObject) Adds a FileObject to the cache.boolean
putFileIfAbsent
(FileObject fileObject) Adds a FileObject to the cache if it isn't already present.void
removeFile
(FileSystem fileSystem, FileName fileName) Removes a file from cache.Methods inherited from class org.apache.commons.vfs2.cache.AbstractFilesCache
touchFile
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, init, setContext, setLogger
-
Constructor Details
-
SoftRefFilesCache
public SoftRefFilesCache()
-
-
Method Details
-
putFile
Description copied from interface:FilesCache
Adds a FileObject to the cache.- Parameters:
fileObject
- the file
-
putFileIfAbsent
Description copied from interface:FilesCache
Adds a FileObject to the cache if it isn't already present.- Parameters:
fileObject
- the file- Returns:
- true if the file was stored, false otherwise.
-
createReference
protected Reference<FileObject> createReference(FileObject file, ReferenceQueue<FileObject> refqueue) -
getFile
Description copied from interface:FilesCache
Retrieves a FileObject from the cache by name.- Parameters:
fileSystem
- The FileSystem.fileName
- 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.
-
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
- filesystemfileName
- filename
-
getOrCreateFilesystemCache
-