Skip to content

elixir-nebulex/nebulex_disk_lfu

Repository files navigation

Nebulex.Adapters.DiskLFU

A Nebulex adapter for a disk-based LFU cache.

CI Codecov Hex Version Documentation

About

Nebulex.Adapters.DiskLFU is a persistent LFU (Least Frequently Used) cache adapter for Nebulex, designed to provide an SSD-backed cache with disk persistence, TTL support, and LFU-based eviction. This adapter is ideal for workloads that require:

  • High-capacity caching without exhausting memory.
  • File-based persistence with cache recovery after restarts.
  • Concurrency-safe operations for both reads and writes.
  • Customizable eviction strategies.

See the Architecture document for more information.


Note

Still under development!

Nebulex.Adapters.DiskLFU is only compatible with Nebulex v3.0.0 or later.


Installation

Add :nebulex_disk_lfu to your list of dependencies in mix.exs:

def deps do
  [
    {:nebulex_disk_lfu, "~> 0.1"}
  ]
end

See the online documentation for more information.

Usage

You can define a cache using as follows:

defmodule MyApp.Cache do
  use Nebulex.Cache,
    otp_app: :my_app,
    adapter: Nebulex.Adapters.DiskLFU
end

Where the configuration for the cache must be in your application environment, usually defined in your config/config.exs:

config :my_app, MyApp.Cache,
  root_path: "/var/cache",
  ...

Benchmarks

Benchmarks were added using benchee, and they are located within the directory benchmarks.

To run the benchmarks:

mix run benchmarks/benchmark.exs

Contributing

Contributions to Nebulex are very welcome and appreciated!

Use the issue tracker for bug reports or feature requests. Open a pull request when you are ready to contribute.

When submitting a pull request you should not update the CHANGELOG.md, and also make sure you test your changes thoroughly, include unit tests alongside new or changed code.

Before to submit a PR it is highly recommended to run mix test.ci and ensure all checks run successfully.

Sponsor

Copyright and License

Copyright (c) 2025, Carlos Bolaños.

Nebulex.Adapters.DiskLFU source code is licensed under the MIT License.

About

A Nebulex adapter for a disk-based LFU cache

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages