public class DefaultFilesCache extends AbstractFilesCache
FilesCache
implementation.
This implementation caches every file with no expire or limit. All files and file systems are hard reachable references. This implementation holds a list of file system specific ConcurrentHashMaps in the main cache map.
Cached FileObjects as well as FileSystems are only removed when
clear(FileSystem)
is called (i.e. on file system close). When the used
FileSystemManager
is closed, it will also close this cache (which frees all entries).
Despite its name, this is not the fallback implementation used by
DefaultFileSystemManager#init()
anymore.
Constructor and Description |
---|
DefaultFilesCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear(FileSystem filesystem)
Purges the entries corresponding to the FileSystem.
|
void |
close()
Closes the provider.
|
FileObject |
getFile(FileSystem filesystem,
FileName name)
Retrieves a FileObject from the cache by name.
|
protected ConcurrentMap<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.
|
touchFile
getContext, getLogger, init, setContext, setLogger
public void putFile(FileObject file)
FilesCache
file
- the filepublic boolean putFileIfAbsent(FileObject file)
FilesCache
file
- the filepublic FileObject getFile(FileSystem filesystem, FileName name)
FilesCache
filesystem
- The FileSystem.name
- the namepublic void clear(FileSystem filesystem)
FilesCache
filesystem
- The FileSystem.protected ConcurrentMap<FileName,FileObject> getOrCreateFilesystemCache(FileSystem filesystem)
public void close()
AbstractVfsComponent
close
in interface Closeable
close
in interface AutoCloseable
close
in interface FilesCache
close
in interface VfsComponent
close
in class AbstractVfsComponent
public void removeFile(FileSystem filesystem, FileName name)
FilesCache
filesystem
- file systemname
- file nameCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.