Currently PINCache only offers LRU (least recently used) as an eviction strategy. However, there are some special workloads where LFU (least frequently used) could offer better performance. This PR introduces LFU alongside the existing LRU eviction strategy. The default is still LRU.
There is also some minor renaming to the trimToSizeByDateAsync, trimToSizeByDate, trimToCostByDate, and trimToCostByDateAsync methods, since those now follow the explicit eviction strategy. Old methods remain and work as expected, but are marked deprecated.
Testing
Added some unit tests for both memory and disk caches to verify objects are evicted based on access count when LFU is selected. Ran tests on iOS, tvOS, macOS.
Summary
Currently PINCache only offers LRU (least recently used) as an eviction strategy. However, there are some special workloads where LFU (least frequently used) could offer better performance. This PR introduces LFU alongside the existing LRU eviction strategy. The default is still LRU.
There is also some minor renaming to the
trimToSizeByDateAsync
,trimToSizeByDate
,trimToCostByDate
, andtrimToCostByDateAsync
methods, since those now follow the explicit eviction strategy. Old methods remain and work as expected, but are marked deprecated.Testing
Added some unit tests for both memory and disk caches to verify objects are evicted based on access count when LFU is selected. Ran tests on iOS, tvOS, macOS.