This video shows how to implement a "timed-memoizing" cache that maps a key to the value produced by a function. If a value has previously been computed it is returned rather than calling the function to compute it again. The Java ConcurrentHashMap.computeIfAbsent() method is used to ensure only a single call to the function is run when a key/value pair is first added to the cache and to eff. The Java ScheduledThreadExecutorService is used in a "one-shot" manner together with Java AtomicLong and ConcurrentHashMap.remove() to limit the amount of time a key/value is retained in the cache.
Download
0 formats
No download links available.
Implementing a "Timed Memoizer" with Java ScheduledExecutorService, ConcurrentHashMap, & AtomicLong | NatokHD