public class FileCache extends Object implements Cache
The FileCache class represents a local on-disk cache in the GroupDocs.Viewer component. It provides functionality to store and retrieve cached data on the disk for efficient document rendering.
Example usage:
FileCache fileCache = new FileCache(cachePath, cacheSubFolder);
final ViewerSettings viewerSettings = new ViewerSettings();
viewerSettings.setCache(fileCache);
try (Viewer viewer = new Viewer(documentPath, viewerSettings)) {
// Use the viewer object for document rendering
}
To use the FileCache, you need to create an instance of this class and pass it to the ViewerSettings object. The Viewer object will then use the FileCache for caching purposes while rendering documents.
Note: The FileCache is just one of the cache implementations provided by GroupDocs.Viewer. You can also implement your own custom cache by implementing the Cache interface.
ViewerSettings,
Viewer| Modifier and Type | Field and Description |
|---|---|
static String |
CACHE_PATH |
| Constructor and Description |
|---|
FileCache(Path cachePath)
Creates a new instance of the
FileCache class. |
FileCache(Path cachePath,
String cacheSubFolder)
Creates a new instance of the
FileCache class. |
FileCache(String cachePath)
Creates a new instance of the
FileCache class. |
FileCache(String cachePath,
String cacheSubFolder)
Creates a new instance of the
FileCache class. |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
get(String key,
Class<T> clazz)
Deserializes data associated with this key if present.
|
String |
getCachePath()
Gets the relative or absolute path to the cache folder.
|
String |
getCacheSubFolder()
The sub-folder to append to the cache path.
|
List<String> |
getKeys(String filter)
Returns all file names that contain the filter in the filename.
|
void |
set(String key,
Object value)
Serializes data to the local disk.
|
public static final String CACHE_PATH
public FileCache(Path cachePath)
Creates a new instance of the FileCache class.
cachePath - The relative or absolute path where the document cache will be stored.IllegalArgumentException - Thrown when cachePath is null.public FileCache(Path cachePath, String cacheSubFolder)
Creates a new instance of the FileCache class.
cachePath - The relative or absolute path where the document cache will be stored.cacheSubFolder - The sub-folder to append to cachePath.IllegalArgumentException - Thrown when cachePath is null.IllegalArgumentException - Thrown when cacheSubFolder is null.public FileCache(String cachePath)
Creates a new instance of the FileCache class.
cachePath - The relative or absolute path where the document cache will be stored.IllegalArgumentException - Thrown when cachePath is null.public FileCache(String cachePath, String cacheSubFolder)
Creates a new instance of the FileCache class.
cachePath - The relative or absolute path where the document cache will be stored.cacheSubFolder - The sub-folder to append to cachePath.IllegalArgumentException - Thrown when cachePath is null.IllegalArgumentException - Thrown when cacheSubFolder is null.public final <T> T get(String key, Class<T> clazz)
Deserializes data associated with this key if present.
public final String getCachePath()
Gets the relative or absolute path to the cache folder.
public final String getCacheSubFolder()
The sub-folder to append to the cache path.
public final List<String> getKeys(String filter)
Returns all file names that contain the filter in the filename.
Copyright © 2024. All rights reserved.