public class FileCacheProvider extends java.lang.Object implements CacheProvider
Constructor and Description |
---|
FileCacheProvider() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Entirely clear the cache content
|
void |
definePaths()
Define the root path
|
<T> T |
get(java.lang.String key)
Getting an entry on the cache
|
java.nio.file.Path |
getCachePath(java.lang.String key)
Returns the path from the given key
|
java.util.List<java.lang.String> |
getKeys()
Returns all keys from a given cache
|
<T> void |
lockAndSet(java.lang.String key,
T entry)
Applies a lock to a cache's file
|
void |
parseConfig(java.io.BufferedReader br)
Parses the config file
|
void |
remove(java.lang.String key)
Removes an entry in the cache
|
<T> void |
set(java.lang.String key,
T entry)
Adding an entry to the cache
|
void |
setCacheFileEntry(java.io.File current,
java.nio.file.Path path)
Sets a file cache entry
|
void |
setExpiry(int expiry)
Reconfigure the expiry after
|
void |
shutdown()
No shutdown operation for this class
|
public void parseConfig(java.io.BufferedReader br) throws java.io.IOException
br
- java.io.IOException
public void definePaths()
public void setCacheFileEntry(java.io.File current, java.nio.file.Path path)
current
- path
- public java.nio.file.Path getCachePath(java.lang.String key) throws java.io.IOException
key
- java.io.IOException
public <T> T get(java.lang.String key) throws CacheException
CacheProvider
get
in interface CacheProvider
T
- cache entrykey
- key of the cache entryCacheException
- when there is cache issues getting by keypublic <T> void lockAndSet(java.lang.String key, T entry) throws CacheException
key
- entry
- CacheException
public <T> void set(java.lang.String key, T entry) throws CacheException
CacheProvider
set
in interface CacheProvider
T
- cache entrykey
- key of the cache entryentry
- cache entryCacheException
- when there is cache issues setting an elementpublic void remove(java.lang.String key) throws CacheException
CacheProvider
remove
in interface CacheProvider
key
- key of the cache entryCacheException
- when there is cache issues removing an entrypublic void clear()
CacheProvider
clear
in interface CacheProvider
public void shutdown()
shutdown
in interface CacheProvider
public java.util.List<java.lang.String> getKeys()
CacheProvider
getKeys
in interface CacheProvider
public void setExpiry(int expiry)
CacheProvider
setExpiry
in interface CacheProvider
expiry
- cache time life in minutes