SuperCache.Bootstrap (SuperCache v1.3.0)

Copy Markdown View Source

Unified startup and shutdown for SuperCache.

Handles both :local (single-node) and :distributed (cluster) modes. The mode is selected via the :cluster option:

Options

OptionTypeDefaultDescription
:key_posinteger0Tuple index used as the ETS key
:partition_posinteger0Tuple index used to select partition
:clusteratom:local:local or :distributed
:num_partitionintegerscheduler countNumber of ETS partitions
:table_typeatom:setETS table type
:table_prefixstring"SuperCache…"Prefix for ETS table atom names

Additional options for :distributed mode (see SuperCache.Cluster.Bootstrap):

OptionTypeDefaultDescription
:replication_factorinteger2Total copies (primary + replicas)
:replication_modeatom:async:async, :sync, or :strong

Examples

Start with defaults (local mode):

SuperCache.Bootstrap.start!()

Start with custom configuration:

opts = [
  key_pos: 0,
  partition_pos: 1,
  num_partition: 8,
  table_type: :bag
]
SuperCache.Bootstrap.start!(opts)

Stop the cache and release all resources:

SuperCache.Bootstrap.stop()

Summary

Functions

Start SuperCache with default options (local mode).

Start SuperCache with the given keyword options.

Stop SuperCache and release all ETS resources.

Functions

start!()

@spec start!() :: :ok

Start SuperCache with default options (local mode).

Uses key_pos: 0, partition_pos: 0, cluster: :local, and table_type: :set. The number of partitions defaults to the number of online schedulers.

Examples

SuperCache.Bootstrap.start!()
# => :ok

start!(opts)

@spec start!(keyword()) :: :ok

Start SuperCache with the given keyword options.

Validates all options before starting. Raises ArgumentError if any option is invalid or missing.

Options

See module documentation for the full list of supported options.

Examples

SuperCache.Bootstrap.start!(key_pos: 0, partition_pos: 1, num_partition: 4)
# => :ok

SuperCache.Bootstrap.start!(cluster: :invalid)
# => ** (ArgumentError) unsupported cluster mode: :invalid

stop()

@spec stop() :: :ok

Stop SuperCache and release all ETS resources.

Gracefully shuts down buffers, storage partitions, and the partition registry. Configuration is preserved so the cache can be restarted with the same settings.

Examples

SuperCache.Bootstrap.stop()
# => :ok