Skip to content

to put objects in cache#8

Open
sytolk wants to merge 1 commit intofhucho:masterfrom
sytolk:master
Open

to put objects in cache#8
sytolk wants to merge 1 commit intofhucho:masterfrom
sytolk:master

Conversation

@sytolk
Copy link

@sytolk sytolk commented Aug 13, 2014

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant