Refreshing a LRU cache
-
09-10-2019 - |
문제
I am implementing a cache using a map extended from LinkedHashMap (so I can implement removeEldestEntry). The old implementation used a regular hash map, refreshed at a set interval. I was wondering how I can keep the data in the cache current. I doubt I can just refresh at a specific time without messing up the point of LRU. Would it be particularly costly to query the DB for a time stamp on the entry?
해결책 2
I ended up going with the LinkedHashMap, ordered by access time and checking against the db for timestamps. This worked like a charm and greatly reduced the memory load of the application.
다른 팁
Why not use OS Cache - no point in reinventing the wheel.
제휴하지 않습니다 StackOverflow