simple-disk-cache
simple-disk-cache copied to clipboard
to put objects in cache
I have replace Apache Commons IO dependence with google guava. And have add new public methods: put(String key, String value, Object[] array) - the value I have use to put the timestamp for max TTL (after this time in ms the cache expired) and: T getArray(String key, Class type)
You can put array from Serializable objects like this: cache.put("key", String.valueOf(new Date().getTime() + 60000), Groups[] arrayGroups);
and get it: Groups[] cacheArray = getCacheArray("key", Groups[].class);
private T getCacheArray(String key, Class type) {
try {
if (cache.contains(key)) {
return cache.getArray(key, type);
}
} catch (IOException e) {
Log.e("getCacheEntry", e.getMessage());
}
return null;
}