Cache.ETS (elixir_cache v0.4.5)

View Source

ETS (Erlang Term Storage) adapter for high-performance in-memory caching.

This adapter provides a fast, process-independent cache using Erlang's built-in ETS tables. It's ideal for applications requiring low-latency access to cached data within a single node.

Features

  • In-memory storage with configurable concurrency options
  • Direct access to ETS-specific operations
  • Very high performance for read and write operations
  • Support for atomic counter operations

Options

  • :write_concurrency - Enable write concurrency

  • :read_concurrency (boolean/0) - Enable read concurrency

  • :decentralized_counters (boolean/0) - Use decentralized counters

  • :type - Data type of ETS cache The default value is :set.

  • :compressed (boolean/0) - Enable ets compression

  • :rehydration_path (String.t/0) - Path to store the ETS table on exit and rehydrate on startup

Example

defmodule MyApp.Cache do
  use Cache,
    adapter: Cache.ETS,
    name: :my_app_cache,
    opts: [
      read_concurrency: true,
      write_concurrency: true
    ]
end

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

all()

child_spec(arg)

Returns a specification to start this module under a supervisor.

arg is passed as the argument to Task.start_link/1 in the :start field of the spec.

For more information, see the Supervisor module, the Supervisor.child_spec/2 function and the Supervisor.child_spec/0 type.

delete_all_objects(cache_name)

delete_object(cache_name, object)

delete_table(cache_name)

file2tab(filename)

file2tab(filename, options)

first(cache_name)

first_lookup(cache_name)

foldl(cache_name, function, acc)

foldr(cache_name, function, acc)

from_dets(cache_name, dets_table)

give_away(cache_name, pid, gift_data)

info(cache_name)

info(cache_name, item)

init_table(cache_name, init_fun)

insert_new(cache_name, data)

insert_raw(cache_name, data)

is_compiled_ms(term)

last(cache_name)

last_lookup(cache_name)

lookup(cache_name, key)

lookup_element(cache_name, key, pos)

lookup_element(cache_name, key, pos, default)

match_delete(cache_name, pattern)

match_object(cache_name, pattern)

match_object(cache_name, pattern, limit)

match_pattern(cache_name, pattern)

match_pattern(cache_name, pattern, limit)

match_spec_compile(match_spec)

match_spec_run(list, compiled_match_spec)

member(cache_name, key)

next(cache_name, key)

next_lookup(cache_name, key)

opts_definition(opts)

prev(cache_name, key)

prev_lookup(cache_name, key)

rename(cache_name, name)

repair_continuation(continuation, match_spec)

safe_fixtable(cache_name, fix)

select(cache_name, match_spec)

select(cache_name, match_spec, limit)

select_count(cache_name, match_spec)

select_delete(cache_name, match_spec)

select_replace(cache_name, match_spec)

select_reverse(cache_name, match_spec)

select_reverse(cache_name, match_spec, limit)

setopts(cache_name, opts)

slot(cache_name, i)

tab2file(cache_name, filename)

tab2file(cache_name, filename, options)

tab2list(cache_name)

tabfile_info(filename)

table(cache_name)

table(cache_name, options)

take(cache_name, key)

test_ms(tuple, match_spec)

to_dets(cache_name, dets_table)

update_counter(cache_name, key, update_op)

update_counter(cache_name, key, update_op, default)

update_element(cache_name, key, element_spec)

update_element(cache_name, key, element_spec, default)

whereis(cache_name)