I have following cache structure where cache key is composite key usecase_actualKey
.
Is it possible to write a custom eviction policy that keep only x entries for useCaseA_*
and y entries of useCaseB_*
myTestCache = {
useCaseA_someKey1 : dummyValue1
useCaseA_someKey2 : dummyValue2
useCaseB_someOtherKey1 : dummyValue1_somestuff
useCaseB_someOtherKey2 : dummyValue1_somestuff2
}
Consider max size of myTestCache is 300
I have 100 entries for useCaseA and 200 for useCaseB
when I make new entry [101 entry] with useCaseA_
I want to evict least frequently element from useCaseA
[we have 100 entries for usecaseA]
This can be easily achieved by mapOfCache like Map<String, CaffeineCache<String, String>>
I checked this thread How many Caffeine Cache instances in an application is too much? . Seems this approach may have GC load.
So I am trying to see if this can be achieved via flat structure