First version, looking at two types of caches differing in their implementation, but much the same in the backend. FlashCache is a simple caching mechanism. You can specify the maximum number of elements, as well as the purge step. The purge step allows for us to specify the step size, or number of elements to clear out when we attempt to add a new element to a full cache.
The SortedCache operates similarly, but requires you to provide a mapping function. This allows us to simply pass in a key, and the cache will compute && cache the result. Further, this allows the cache to keep track of compute times for each entry. Rather than purging based on maximum number of elements, this cache purges the least compute intensive elements when it determines that memory pressure has risen above a certain threshold.