0

my Caffeine cache works perfectly. But, i would like to improve its performances.

In fact, many of keys i want to load from my cache are not in the database. Is there a way that Caffeine put all theses unreachable keys in the map, so that when i request again to the Caffeine cache, caffeine does NOT REQUEST AGAIN to the database ?

exemple :

  key FR12333 : exist in DB ==> is put in the cache as ("FR12333","something")

  key FR76663 : exist in DB ==> is put in the cache as ("FR76663","something")

  key FR88888 : DO NOT exist in DB ==> is put in the cache as ("FR88888",null)

is there a way/option to do that ?

electrode
  • 205
  • 1
  • 4
  • 16
  • You can use negative caching, e.g. where the value is an `Optional`. That way the cache maintains an entry indicating its absence in the data store. – Ben Manes May 20 '21 at 15:25
  • @BenManes absoluty correct ! works perfectly using Optional as Object Wrapper. many thanks. – electrode May 21 '21 at 13:06

0 Answers0