FileCache
Leave feedback
On this page
Inheritance: java.lang.Object
All Implemented Interfaces: com.groupdocs.viewer.caching.Cache
public class FileCache implements Cache
Represents a local on-disk 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.
| Constructor | Description |
|---|---|
| FileCache(String cachePath) | Creates a new instance of the FileCache class. |
| FileCache(Path cachePath) | Creates a new instance of the FileCache class. |
| FileCache(String cachePath, String cacheSubFolder) | Creates a new instance of the FileCache class. |
| FileCache(Path cachePath, String cacheSubFolder) | Creates a new instance of the FileCache class. |
| Field | Description |
|---|---|
| CACHE_PATH |
| Method | Description |
|---|---|
| getCachePath() | Gets the relative or absolute path to the cache folder. |
| getCacheSubFolder() | The sub-folder to append to the cache path. |
| set(String key, Object value) | Serializes data to the local disk. |
| Deserializes data associated with this key if present. | |
| getKeys(String filter) | Returns all file names that contain the filter in the filename. |
public FileCache(String cachePath)
Creates a new instance of the FileCache class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| cachePath | java.lang.String | The relative or absolute path where the document cache will be stored. |
public FileCache(Path cachePath)
Creates a new instance of the FileCache class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| cachePath | java.nio.file.Path | The relative or absolute path where the document cache will be stored. |
public FileCache(String cachePath, String cacheSubFolder)
Creates a new instance of the FileCache class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| cachePath | java.lang.String | The relative or absolute path where the document cache will be stored. |
| cacheSubFolder | java.lang.String | The sub-folder to append to cachePath . |
public FileCache(Path cachePath, String cacheSubFolder)
Creates a new instance of the FileCache class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| cachePath | java.nio.file.Path | The relative or absolute path where the document cache will be stored. |
| cacheSubFolder | java.lang.String | The sub-folder to append to cachePath . |
public static final String CACHE_PATH
public final String getCachePath()
Gets the relative or absolute path to the cache folder.
Returns: java.lang.String - Path to the cache folder.
public final String getCacheSubFolder()
The sub-folder to append to the cache path.
Returns: java.lang.String - the sub-folder to append.
public final void set(String key, Object value)
Serializes data to the local disk.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| key | java.lang.String | The unique identifier for the cache entry. |
| value | java.lang.Object | The object to serialize. |
public final T <T>get(String key, Class<T> clazz)
Deserializes data associated with this key if present.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| key | java.lang.String | A key identifying the requested entry. |
| clazz | java.lang.Class |
The class of the expected value. |
Returns: T - the located value or null.
public final List<String> getKeys(String filter)
Returns all file names that contain the filter in the filename.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| filter | java.lang.String | The filter to use. |
Returns: java.util.List<java.lang.String> - File names that contain the filter in the filename.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.