public class LRUFilesCache extends AbstractFilesCache
LRUMap
.
The default constructor uses a LRU size of 100 per file system.
Modifier and Type | Class and Description |
---|---|
private class |
LRUFilesCache.MyLRUMap
The file cache
|
Modifier and Type | Field and Description |
---|---|
private static int |
DEFAULT_LRU_SIZE
The default LRU size
|
private java.util.concurrent.ConcurrentMap<FileSystem,java.util.Map<FileName,FileObject>> |
filesystemCache
The FileSystem cache
|
private static org.apache.commons.logging.Log |
log
The logger to use.
|
private int |
lruSize
The size of the cache
|
private java.util.concurrent.locks.Lock |
readLock |
private java.util.concurrent.locks.ReadWriteLock |
rwLock |
private java.util.concurrent.locks.Lock |
writeLock |
Constructor and Description |
---|
LRUFilesCache()
Default constructor.
|
LRUFilesCache(int lruSize)
Set the desired LRU size.
|
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 java.util.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) |
getContext, getLogger, init, setContext, setLogger
private static final int DEFAULT_LRU_SIZE
private static final org.apache.commons.logging.Log log
private final java.util.concurrent.ConcurrentMap<FileSystem,java.util.Map<FileName,FileObject>> filesystemCache
private final int lruSize
private final java.util.concurrent.locks.ReadWriteLock rwLock
private final java.util.concurrent.locks.Lock readLock
private final java.util.concurrent.locks.Lock writeLock
public LRUFilesCache()
public LRUFilesCache(int lruSize)
lruSize
- the LRU sizepublic 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 java.util.Map<FileName,FileObject> getOrCreateFilesystemCache(FileSystem filesystem)
public void close()
AbstractVfsComponent
close
in interface FilesCache
close
in interface VfsComponent
close
in class AbstractVfsComponent
public void removeFile(FileSystem filesystem, FileName name)
FilesCache
filesystem
- file systemname
- file namepublic void touchFile(FileObject file)
touchFile
in class AbstractFilesCache