View Source Fuzler (Fuzler v0.1.0)
A lightweight, reusable cache built on an ETS table, wrapped in a GenServer.
highlights
Highlights
- Named ETS – give any atom as
:table. - Public reads / protected writes –
:public,read_concurrency:&write_concurrency:enabled; only the owner process mutates the table. - O(1) table lookup – mapping from server‐name → table stored in
:persistent_term, avoiding aGenServer.call/2round‑trip for every public API invocation. - Hot reload, insert, get, predicate stream – as before.
- Fuzzy full‑text search on keys –
text_search/3usesString.jaro_distance/2(or any custom scorer) and thresholding.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Fetches value for key, or nil if not present.
Inserts a {key, value} tuple into the cache.
Reloads the cache by wiping the table and invoking the loader again.
Starts the cache.
Returns a lazy stream of {key, value} pairs whose value satisfies
predicate.(value). When no predicate given, returns every entry.
Top‐N fuzzy search selecting the scorer based on table size
Link to this section Types
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get(key(), GenServer.server()) :: value() | nil
Fetches value for key, or nil if not present.
@spec insert( {key(), value()}, GenServer.server() ) :: :ok
Inserts a {key, value} tuple into the cache.
@spec reload(GenServer.server()) :: :ok
Reloads the cache by wiping the table and invoking the loader again.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the cache.
Options:
:table– required atom, the ETS table name.:loader– required() -> Enumerable.t()that yields{key, value}.:ets_opts– extra ETS options merged with sensible defaults[:named_table, :public, read_concurrency: true, write_concurrency: true].:name– process name (defaults to the module itself).
@spec stream((value() -> as_boolean(term())) | nil, GenServer.server()) :: Enumerable.t()
Returns a lazy stream of {key, value} pairs whose value satisfies
predicate.(value). When no predicate given, returns every entry.
Top‐N fuzzy search selecting the scorer based on table size:
If the cache has fewer than
@key_count_thresholdentries, uses pure‐ElixirString.jaro_distance/2.Otherwise uses the SIMD‐accelerated
nif_similarity_score/2.query– the search string.opts–:limit(default 15).
Returns a list of {key, value, score} sorted by descending similarity.