문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top