In progress ...
The face book story
https://research.fb.com/the-evolution-of-advanced-caching-in-the-facebook-cdn/
Cache algorithms : Know How ?
Cache algorithms : Best Practices
https://vladmihalcea.com/caching-best-practices/
Cache algorithms : Third Party Options
Gauva cache
https://dzone.com/articles/google-guava-cache
Echache
Cache algorithms : Implementing your own API
https://www.quora.com/What-is-the-best-way-to-Implement-an-LRU-Cache
https://www.careercup.com/question?id=5743058519851008
https://www.careercup.com/question?id=5743058519851008
Citigroup Interview Question Financial Software Developers
LRU
http://www.javarticles.com/2012/06/lru-cache.html
https://www.careercup.com/question?id=17230678
https://www.programcreek.com/2013/03/leetcode-lru-cache-java/
http://www.ideserve.co.in/learn/lru-cache-implementation
-
https://gist.github.com/vidz2015/39eeb613a80b54e072481209cffc7551
-
https://www.careercup.com/question?id=17230678
https://www.programcreek.com/2013/03/leetcode-lru-cache-java/
http://www.ideserve.co.in/learn/lru-cache-implementation
-
https://gist.github.com/vidz2015/39eeb613a80b54e072481209cffc7551
-
1.Define a map, queue, int maxsize of your choice ,
2.The put operation is critical,
- Check if map already has the key ,if so remove it from the queue ,as we need to add the key on the top
- Iterate over the queue , to get the oldest key ,,remove it ,add the key & then store value against this key in the map.
print 'hello world!'public class ConcurrentLRUCache{ private final int maxSize; private ConcurrentHashMap map; private ConcurrentLinkedQueue queue; public ConcurrentLRUCache(final int maxSize) { this.maxSize = maxSize; map = new ConcurrentHashMap (maxSize); queue = new ConcurrentLinkedQueue (); } /** * */ public void put(final Key key, final Value value) { if (map.containsKey(key)) { queue.remove(key); // remove the key from the FIFO queue } while (queue.size() >= maxSize) { Key oldestKey = queue.poll(); if (null != oldestKey) { map.remove(oldestKey); } } queue.add(key); map.put(key, value); } /** * @param key - may not be null! * @return the value associated to the given key or null */ public Value get(final Key key) { return map.get(key); }
LFU
http://www.javarticles.com/2012/06/lfu-cache.html
http://dhruvbird.com/lfu.pdf
MRU
To do (Check the following Links in spare time)
https://youtu.be/MylI8HmgMBk
https://youtu.be/MylI8HmgMBk
No comments:
Post a Comment