Implementation of the LFU-group of caching algorithms. Now, LFU-DA is now one of the most efficient caching algorithms for web-related tasks.
The package provides a thread-safe in-memory implementation of the Least Frequency Used cache based on a min binary heap map. There are three policies for calculating the priority key, see here for more information
- LFU policy
- LFU with Dynamic Age policy (by default)
- GreedyDual-Size with Frequency (GDSF)
LFUDA implements AbstractDict
interface. Usage examples:
lfuda = LFUDA{String,String}(maxsize = 2)
lfuda["key"] = "cache_1"
cache_1 = get(lfuda, "key", nothing) # Now cache 1 have frequency equal to 2
value = "cache_2"
# Pass value size, necessary for GDSF policy
cache_2 = get!(lfuda, "key_2", value, size=sizeof(value)) # Cache 2 have frequncy equal to 1
lfuda["key_3"] = "cache_3" # In this case cache_2 will be evicted
@show haskey(lfuda, "key_2")