java - How to let missing entries expire more quickly in Guava -
i have java service translates string key long id, through database lookup. i'm wrapping in guava cache reduce database queries. mapping key id doesn't change once it's set, can use long expire time existing keys. there timing issue (not in guava in app) might lookup id key before in database. not want cache "missing" mapping long. want cache though, avoid rush of queries same missing key. i read question: handle null value ... , , there cobbled solution 2 caches. have "missing keys" cache, let expire more , has no auto-load function. check cache first, , if find there know it's missing key. otherwise, try "real" cache, catching executionexception indicate "missing" , manually populate "missing keys" cache. feels quite awkward, part throw exception in load method when there's no mapping. wonder if there isn't more elegant way handle kind of problem. you might try based on refresh , implem...