# \[ANN\] Announcing LFUDACache.jl

**URL:** https://discourse.julialang.org/t/ann-announcing-lfudacache-jl/105254
**Category:** Package Announcements
**Created:** [October 21, 2023, 12:09am UTC](https://discourse.julialang.org/t/ann-announcing-lfudacache-jl/105254 "2023-10-21T00:09:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rssdev10](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rssdev10](https://discourse.julialang.org/u/rssdev10)
#### Post date: [October 21, 2023, 12:09am UTC](https://discourse.julialang.org/t/ann-announcing-lfudacache-jl/105254/1 "2023-10-21T00:09:33Z")

</div>

[Implementation of the LFU-group](https://github.com/OpenSesame/LFUDACache.jl) 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](https://www.hpl.hp.com/techreports/98/HPL-98-173.pdf)

1. LFU policy
2. LFU with Dynamic Age policy (by default)
3. GreedyDual-Size with Frequency (GDSF)

LFUDA implements `AbstractDict` interface. Usage examples:

```julia
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")

```
