Cache.ETS (elixir_cache v0.3.9)

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 (boolean/0) - 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

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

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.