public class

FileCache

extends Object
implements Cache
java.lang.Object
   ↳ com.neomades.content.cache.FileCache
Known Direct Subclasses

Class Overview

Cache implementation that caches files directly onto the hard disk in the specified directory. Cache data are refreshed using the CacheEntry mechanism: data are updated only if the server indicates that they need to be updated. The use of this cache required some server configuration to send the good headers with the response else the data will be updated each time a query is done. Refer to CacheEntry documentation to have more information about the server headers to send.

The default disk usage size is 5MB, but is configurable.

Summary

Public Constructors
FileCache(File rootDirectory, int maxCacheSizeInBytes)
Constructs an instance of the FileCache at the specified directory.
FileCache(File rootDirectory)
Constructs an instance of the FileCache at the specified directory using the default maximum cache size of 5MB.
Public Methods
void clear()
Clears the cache.
CacheEntry get(String key)
Gets the CacheEntry associated with the given key.
void initialize()
Performs any potentially long-running actions needed to initialize the cache.
void invalidate(String key, boolean fullExpire)
Invalidates an entry in the cache.
void put(String key, CacheEntry entry)
Adds or replaces an CacheEntry in the cache.
void remove(String key)
Removes an entry from the cache.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.neomades.content.cache.Cache

Public Constructors

public FileCache (File rootDirectory, int maxCacheSizeInBytes)

Constructs an instance of the FileCache at the specified directory.

Do not use the same directory with different caches of FileCache, FileImageCache, DefaultFileCache or other caches.
FileCache will delete all the files which is not a file handled by this cache.

Parameters
rootDirectory The root directory of the cache.
maxCacheSizeInBytes The maximum size of the cache in bytes.

public FileCache (File rootDirectory)

Constructs an instance of the FileCache at the specified directory using the default maximum cache size of 5MB.

Parameters
rootDirectory The root directory of the cache.

Public Methods

public void clear ()

Clears the cache.

public CacheEntry get (String key)

Gets the CacheEntry associated with the given key. Using this type of CacheEntry, data are updated only if the server indicates that they need to be updated.

Parameters
key the cache key
Returns

public void initialize ()

Performs any potentially long-running actions needed to initialize the cache. Will be called from a worker thread.

public void invalidate (String key, boolean fullExpire)

Invalidates an entry in the cache.

Parameters
key the cache key
fullExpire true to ignore the current cache data

public void put (String key, CacheEntry entry)

Adds or replaces an CacheEntry in the cache.

Parameters
key the cache key
entry Data to store in the cache

public void remove (String key)

Removes an entry from the cache.

Parameters
key the cache key