Packages
vela_cache
0.1.0
A distributed cache library for Elixir with pluggable backends, topologies, and near-cache support.
Current section
Files
Jump to
Current section
Files
lib/vela.ex
defmodule Vela do
@moduledoc """
Vela is a distributed cache library for Elixir.
## Quick Start
defmodule MyApp.Cache do
use Vela.Cache,
backend: Vela.Backend.ETS,
topology: Vela.Topology.Local,
default_ttl: :timer.minutes(5)
end
# Add to your supervision tree
children = [MyApp.Cache]
# Use it
MyApp.Cache.put(:key, "value")
MyApp.Cache.get(:key) # => {:ok, "value"}
## Backends
- `Vela.Backend.ETS` — in-memory, fastest (default)
- `Vela.Backend.DETS` — disk-persistent, survives restarts
- `Vela.Backend.Redis` — external Redis server (requires `:redix`)
## Topologies
- `Vela.Topology.Local` — single node, no distribution (default)
- `Vela.Topology.Replicated` — full copy on every node, local reads
- `Vela.Topology.Partitioned` — sharded across nodes via consistent hash ring
## Near Cache
Add a local ETS read-through layer in front of any topology:
use Vela.Cache,
backend: Vela.Backend.Redis,
topology: Vela.Topology.Local,
near_cache: true,
near_cache_l1_ttl: :timer.seconds(30)
"""
end