org.opencms.cache
Class CmsVfsNameBasedDiskCache

java.lang.Object
  extended by org.opencms.cache.CmsVfsNameBasedDiskCache

public class CmsVfsNameBasedDiskCache
extends Object

Implements a name based RFS file based disk cache, that handles parameter based versions of VFS files, providing a cache for the "online" and another for the "offline" project.

This RFS cache operates only on the file names, not on the RFS "date last modified" information.

Since:
6.2.0
Version:
$Revision: 1.2 $
Author:
Alexander Kandzior

Constructor Summary
CmsVfsNameBasedDiskCache(String basepath, String foldername)
          Creates a new disk cache.
 
Method Summary
 byte[] getCacheContent(String rfsName)
          Returns the content of the requested file in the disk cache, or null if the file is not found in the cache, or is found but outdated.
 String getCacheName(CmsResource resource, boolean online, String parameters)
          Returns the RFS name to use for caching the given VFS resource with parameters in the disk cache.
 String getRepositoryPath()
          Returns the absolute path of the cache repository in the RFS.
 void saveCacheFile(String rfsName, byte[] content)
          Saves the given file content in the disk cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsVfsNameBasedDiskCache

public CmsVfsNameBasedDiskCache(String basepath,
                                String foldername)
Creates a new disk cache.

Parameters:
basepath - the base path for the cache in the RFS
foldername - the folder name for this cache, to be used a subfolder for the base folder
Method Detail

getCacheContent

public byte[] getCacheContent(String rfsName)
Returns the content of the requested file in the disk cache, or null if the file is not found in the cache, or is found but outdated.

Parameters:
rfsName - the file RFS name to look up in the cache
Returns:
the content of the requested file in the VFS disk cache, or null

getCacheName

public String getCacheName(CmsResource resource,
                           boolean online,
                           String parameters)
Returns the RFS name to use for caching the given VFS resource with parameters in the disk cache.

Parameters:
online - if true, the online disk cache is used, the offline disk cache otherwise
parameters - the parameters of the request to the VFS resource
resource - the VFS resource to generate the cache name for
Returns:
the RFS name to use for caching the given VFS resource with parameters

getRepositoryPath

public String getRepositoryPath()
Returns the absolute path of the cache repository in the RFS.

Returns:
the absolute path of the cache repository in the RFS

saveCacheFile

public void saveCacheFile(String rfsName,
                          byte[] content)
                   throws IOException
Saves the given file content in the disk cache.

Parameters:
rfsName - the RFS name of the file to save the content in
content - the content of the file to save
Throws:
IOException - in case of disk access errors