Summary: Ctors | Methods | Inherited Methods | [Expand All]
public class

# RecentlyUsedCache

extends Object

java.lang.Object
↳ | com.pdftron.common.RecentlyUsedCache

## Class Overview

RecentlyUsedCache is a persistent cache that provides thumbnails for recently used documents in PDFNet. The cache is stored in the persistent cache folder, which can be set by calling PDFNet.setPersistentCachePath(java.lang.String). The cache will be used by any PDFNet process that uses the resource path. If more than one PDFNet process is running concurrently, the first process to acquire a lock on the cache will use it. Subsequent processes will not read or modify the cache. Recently used cache will track the order of N recently used documents, and store references to generated PNG thumbnails for those documents. Most of this functionality happens 'magically', without any necessary user action.

## Summary

Public Constructors
| RecentlyUsedCache()

Public Methods
static void | accessDocument(String uuid, PDFDoc doc) Marks the document as having been accessed.
static void | accessDocument(String document_path) Marks the document as having been accessed.
static String | getBitmapPathIfExists(String document_path) Get the path to the thumbnail PNG associated with the document.
static boolean | hasBeenInitialized() Returns true if RecentlyUsedCache has been initialized.
static void | initializeRecentlyUsedCache(long num_documents, long max_absolute_space, double max_percentage_space) Initialize the Recently used cache with the provided limits.
static void | removeDocument(String document_path) Removes the document from the recently used list.
static void | renameDocument(String old_path, String new_path) Renames a document from the recently used list.
static void | resetCache() Blast away the cache from the disk completely, removing any thumbnails and recently used state.

[Expand] Inherited Methods
From class java.lang.Object
boolean | equals(Object arg0)
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Constructors

#### public RecentlyUsedCache ()

## Public Methods

#### public static void accessDocument (String uuid, PDFDoc doc)

Marks the document as having been accessed. This happens implicitly when calling PDFViewCtrl.setDoc, but depending on your use case, you may also want to call it explicitly. Does nothing if RecentlyUsedCache was not initialized successfully.

##### Parameters

uuid | Unique ID.
doc | The document.

#### public static void accessDocument (String document_path)

Marks the document as having been accessed. This happens implicitly when calling PDFViewCtrl.setDoc, but depending on your use case, you may also want to call it explicitly. Does nothing if RecentlyUsedCache was not initialized successfully.

##### Parameters

document_path | path to the document being accessed.

#### public static String getBitmapPathIfExists (String document_path)

Get the path to the thumbnail PNG associated with the document. Even if the document is in the recently accessed list, there is no guarantee it will have an associated PNG. Does nothing if RecentlyUsedCache was not initialized successfully.

##### Parameters

document_path | path to the document whose bitmap you want to retrieve.

##### Returns

- the path to the PNG bitmap, if it exists. Otherwise, an empty string.

#### public static boolean hasBeenInitialized ()

Returns true if RecentlyUsedCache has been initialized.

#### public static void initializeRecentlyUsedCache (long num_documents, long max_absolute_space, double max_percentage_space)

Initialize the Recently used cache with the provided limits. If the cache already exists, it will shrink to conform to these limits immediately

##### Parameters

num_documents | the number of documents to track in the recently used list.
max_absolute_space | the maximum space, in bytes, the thumbnails can occupy on disk.
max_percentage_space | the maximum percentage of free space, in range 0 - 1.0, the thumbnails can occupy on disk.

##### Throws

PDFNetException |

#### public static void removeDocument (String document_path)

Removes the document from the recently used list. Does nothing if RecentlyUsedCache was not initialized successfully.

##### Parameters

document_path | path to the document to remove.

#### public static void renameDocument (String old_path, String new_path)

Renames a document from the recently used list. Does nothing if RecentlyUsedCache was not initialized successfully.

##### Parameters

old_path | old path of the document.
new_path | new path of the document.

#### public static void resetCache ()

Blast away the cache from the disk completely, removing any thumbnails and recently used state. You may want to do this if you detect some kind of corruption, or if the user wants to clear out disk space used by your application. Does nothing if RecentlyUsedCache was not initialized successfully.