java.lang.Object | |
↳ | com.neomades.content.cache.FileCache |
![]() |
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.
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
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.
rootDirectory | The root directory of the cache. |
---|---|
maxCacheSizeInBytes | The maximum size of the cache in bytes. |
Constructs an instance of the FileCache
at the specified
directory using the default maximum cache size of 5MB.
rootDirectory | The root directory of the cache. |
---|
Clears the cache.
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.
key | the cache key |
---|
CacheEntry
or null
if the CacheEntry
can not be found.
Performs any potentially long-running actions needed to initialize the cache. Will be called from a worker thread.
Invalidates an entry in the cache.
key | the cache key |
---|---|
fullExpire | true to ignore the current cache data
|
Adds or replaces an CacheEntry
in the cache.
key | the cache key |
---|---|
entry | Data to store in the cache |