public class Cache extends Object
IOUtils.read(java.io.File)
.
Once created, cachable objects are saved using either IOUtils.writeASCII(java.io.File, WriteableASCII)
or
IOUtils.writeBinary(java.io.File, WriteableBinary)
Constructor and Description |
---|
Cache() |
Modifier and Type | Method and Description |
---|---|
static void |
clear(Cachable instance)
Clear the cache entry for a given cachable object
|
static <T extends Cachable> |
clear(Class<T> clazz,
Object... objects)
Clear the cache entry for a given clazz and a set of constructors
|
static <T> T |
load(Class<? extends T> clazz,
Object... objects)
Create an instance of the clazz for the objects (for the constructor).
|
static <T> T |
load(T instance)
load an instance using
load(Object, Class, boolean) with class as instance#getClass. |
static <T> T |
load(T instance,
Class<? extends T> clazz,
boolean skipcache) |
static <T> T |
loadSkipCache(Class<? extends T> clazz,
Object... objects)
Create an instance of the clazz for the objects (for the constructor).
|
static void |
main(String[] args) |
public Cache()
public static <T> T load(T instance)
load(Object, Class, boolean)
with class as instance#getClass. The cache lookup is not
skipped.T
- instance
- public static <T> T load(Class<? extends T> clazz, Object... objects)
Cachable
instances, an attempt is made to load
the instance from the Cache.T
- The type of the object returnedclazz
- the class which to get a cached instance ofobjects
- the parameters used to instantiate and index the cached objectpublic static <T> T loadSkipCache(Class<? extends T> clazz, Object... objects)
Cachable
instances, an attempt is made to load
the instance from the Cache.T
- The type of the object returnedclazz
- the class which to get a cached instance ofobjects
- the parameters used to instantiate and index the cached objectpublic static <T extends Cachable> void clear(Class<T> clazz, Object... objects)
T
- clazz
- objects
- public static void clear(Cachable instance)
instance
- public static <T> T load(T instance, Class<? extends T> clazz, boolean skipcache)
T
- The type of the object returnedinstance
- the instance to attempt to load from the cache if the instance is Cachable
clazz
- the class which to get a cached instance ofskipcache
- force the cache to be skipped, for a new instance to be returned