org.apache.commons.vfs.cache
Class LRUFilesCache

java.lang.Object
  extended by org.apache.commons.vfs.provider.AbstractVfsComponent
      extended by org.apache.commons.vfs.cache.AbstractFilesCache
          extended by org.apache.commons.vfs.cache.LRUFilesCache
All Implemented Interfaces:
FilesCache, VfsComponent

public class LRUFilesCache
extends AbstractFilesCache

This implementation caches every file using LRUFilesCache.MyLRUMap.
The default constructor uses a LRU size of 100 per filesystem.

Version:
$Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Mi, 29 Nov 2006) $
Author:
Mario Ivankovits

Nested Class Summary
private  class LRUFilesCache.MyLRUMap
           
 
Field Summary
private  java.util.Map filesystemCache
           
private  org.apache.commons.logging.Log log
          The logger to use.
private  int lruSize
           
 
Constructor Summary
LRUFilesCache()
          Default constructor.
LRUFilesCache(int lruSize)
          Set the desired LRU size.
 
Method Summary
 void clear(FileSystem filesystem)
          purge the entries corresponding to the filesystem
 void close()
          Closes the provider.
 FileObject getFile(FileSystem filesystem, FileName name)
          retrieve a file from the cache by its name
protected  java.util.Map getOrCreateFilesystemCache(FileSystem filesystem)
           
 void putFile(FileObject file)
          add a fileobject to the cache
 void removeFile(FileSystem filesystem, FileName name)
          removes a file from cache
 void touchFile(FileObject file)
           
 
Methods inherited from class org.apache.commons.vfs.provider.AbstractVfsComponent
getContext, getLogger, init, setContext, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log
The logger to use.


filesystemCache

private final java.util.Map filesystemCache

lruSize

private final int lruSize
Constructor Detail

LRUFilesCache

public LRUFilesCache()
Default constructor. Uses a LRU size of 100 per filesystem.


LRUFilesCache

public LRUFilesCache(int lruSize)
Set the desired LRU size.

Parameters:
lruSize - the LRU size
Method Detail

putFile

public void putFile(FileObject file)
Description copied from interface: FilesCache
add a fileobject to the cache

Parameters:
file - the file

getFile

public FileObject getFile(FileSystem filesystem,
                          FileName name)
Description copied from interface: FilesCache
retrieve a file from the cache by its name

name - the name
Returns:
the fileobject or null if file is not cached

clear

public void clear(FileSystem filesystem)
Description copied from interface: FilesCache
purge the entries corresponding to the filesystem


getOrCreateFilesystemCache

protected java.util.Map getOrCreateFilesystemCache(FileSystem filesystem)

close

public void close()
Description copied from class: AbstractVfsComponent
Closes the provider. This implementation does nothing.

Specified by:
close in interface FilesCache
Specified by:
close in interface VfsComponent
Overrides:
close in class AbstractVfsComponent

removeFile

public void removeFile(FileSystem filesystem,
                       FileName name)
Description copied from interface: FilesCache
removes a file from cache

Parameters:
filesystem - filesystem
name - filename

touchFile

public void touchFile(FileObject file)