Thread-safe in memory implementation of Least Frequency Used cache based on min binary heap map. Package provides three policies for calculation of priority key (more information here)
- LFU policy
- LFU with Dynamic Age policy (by default)
- GreedyDual-Size with Frequency (GDSF)
LFUDA implements AbstractDict interface. Here some examples of usage:
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")
This package inspired by LRUCache.jl, lfuda-go and squid-cache