This is my first time posting a question here,and I'm new to Guava Cache, so please bare with me :).
Regarding the cache keys - In the DB itself the relation between my key to the values I'm extracting is one-to-many.
Let's say I have the following scenario when my cache is configured as <String, List> - Looking for "key1".
In a given cache state I have:
"key1" -> (val1, val2, val3,...).
And in the DB I have in addition:
"key1" - val4, "key1" - val5.
Now, as I understand it, only if the LoadingCache will notice there's a missing key it'll query the db. So in this scenario It won't load the missing values I need, as it sees the keys in the cache - resulting in missing data loading.
You can add
refreshAfterWriteto the cache builder so it automatically refreshes the cache after certain time period.But the best option would be if you have access to the part of code that does value update in DB to update the cache after it.