RedisServerWrapper.Manager (redis_server_wrapper v0.7.2)

Copy Markdown View Source

Persistent instance manager for Redis server processes.

Tracks instances across IEx sessions via a JSON state file. Instances are detached by default so they outlive the Elixir process that started them.

Usage

Manager.start_basic(port: 6400)
Manager.start_cluster(masters: 3, base_port: 7100)
Manager.start_sentinel(master_port: 6390)

Manager.list()
Manager.info("redis-basic-1")
Manager.stop("redis-basic-1")
Manager.cleanup()

State is stored at ~/.config/redis-server-wrapper/instances.json.

Summary

Functions

Removes instances from state that are no longer running.

Gets detailed info for a named instance, including live status.

Lists all tracked instances. Optionally filter by type: :basic, :cluster, :sentinel.

Starts a basic single-node Redis instance.

Starts a Redis Cluster.

Starts a Redis Sentinel topology.

Stops a named instance by sending SHUTDOWN to all its processes.

Stops all tracked instances.

Types

instance()

@type instance() :: %{
  name: String.t(),
  type: instance_type(),
  created_at: String.t(),
  bind: String.t(),
  ports: [non_neg_integer()],
  pids: [non_neg_integer()],
  password: String.t() | nil,
  url: String.t(),
  metadata: map()
}

instance_type()

@type instance_type() :: :basic | :cluster | :sentinel

Functions

cleanup()

@spec cleanup() :: {non_neg_integer(), non_neg_integer()}

Removes instances from state that are no longer running.

info(name)

@spec info(String.t()) :: {:ok, map()} | {:error, :not_found}

Gets detailed info for a named instance, including live status.

list(type \\ nil)

@spec list(instance_type() | nil) :: [instance()]

Lists all tracked instances. Optionally filter by type: :basic, :cluster, :sentinel.

start_basic(opts \\ [])

@spec start_basic(keyword()) :: {:ok, instance()} | {:error, term()}

Starts a basic single-node Redis instance.

Options

  • :name - instance name (auto-generated if omitted)
  • :port - Redis port (default: 6379)
  • :password - Redis password (auto-generated if omitted, pass nil for no auth)
  • :bind - bind address (default: "127.0.0.1")
  • :persist - enable persistence (default: false)
  • :maxmemory - memory limit (e.g., "256mb")
  • :loadmodule - modules to load; accepts paths or {path, [args]} tuples
  • Plus any RedisServerWrapper.Config options via :extra

start_cluster(opts \\ [])

@spec start_cluster(keyword()) :: {:ok, instance()} | {:error, term()}

Starts a Redis Cluster.

Options

  • :name - instance name (auto-generated if omitted)
  • :masters - number of masters (default: 3)
  • :replicas_per_master - replicas per master (default: 0)
  • :base_port - starting port (default: 7100)
  • :password - Redis password (auto-generated if omitted)
  • :bind - bind address (default: "127.0.0.1")
  • :loadmodule - modules loaded into every cluster node

start_sentinel(opts \\ [])

@spec start_sentinel(keyword()) :: {:ok, instance()} | {:error, term()}

Starts a Redis Sentinel topology.

Options

  • :name - instance name (auto-generated if omitted)
  • :master_port - master port (default: 6390)
  • :replicas - number of replicas (default: 2)
  • :sentinels - number of sentinels (default: 3)
  • :sentinel_base_port - starting sentinel port (default: 26389)
  • :password - Redis password (auto-generated if omitted)
  • :bind - bind address (default: "127.0.0.1")
  • :loadmodule - modules loaded into the master and every replica

stop(name)

@spec stop(String.t()) :: :ok | {:error, :not_found}

Stops a named instance by sending SHUTDOWN to all its processes.

stop_all()

@spec stop_all() :: :ok

Stops all tracked instances.