LRU cache
You need to write an in-memory image cache with LRU eviction yourself. Which data structures give you O(1) get and put?
You need to write an in-memory image cache with LRU eviction yourself. Which data structures give you O(1) get and put?
A Dictionary (key to node) plus a doubly linked list (recency order) gives O(1) get and put. NSCache's eviction policy is opaque and its cost limit is approximate, so when you need exact LRU and capacity control, you build your own.
PersistenceShort answerBasics
NSCache exists, so why do image libraries write their own LRU cache?
#lru #linked-list #nscache #image-cache
CS fundamentals and algorithmsShort answerAdvanced
You've implemented an LRU cache and the interviewer follows up: "Now make each entry…
#lru #cache #linked-list
PersistenceMultiple choiceBasics
You picked LRU for an image cache. Select all the correct statements about LRU.
#lru #cache #linked-list
NetworkingMultiple choiceBasics
Select all the statements that correctly describe how NSCache differs from Dictionary.
#cache #dictionary #nscache