Here is the background: I have a 1 billion users in my external storage and most of them will be accessed at least once in a day, but only some active data will be accessed much more.
So for Guava, I may write:
cache.get(key, new Callable() {
Call() {
return getExternal(key);
}
});
However, Guava will cache the object into memory every time I load from external storage. But since I have a very large data set, and the very inactive data will be also loaded into memory and then exceed the max size, thus really active data will possibly be eliminated.
So I hope to control Guava, telling it that this data is not intended to be cached, like that:
cache.get(key, new Callable() {
Call() {
MyObject o = getExternal(key);
if (!o.isActive()) {
...//do NOT cache
}
}
});
Is it possible to achieve this goal in Guava?