Exredis.Sub

Subscribe functions for exredis

Source

Summary

psubscribe(client, channel, term)

Subscribe to a channel by pattern

start_link()
start_link(host, port, password \\ "", reconnect \\ :no_reconnect, max_queue \\ :infinity, behaviour \\ :drop)

Connect to the Redis server for subscribe to a channel

start_using_connection_string(connection_string \\ "redis://127.0.0.1:6379", reconnect \\ :no_reconnect, max_queue \\ :infinity, behaviour \\ :drop)

Connect to the Redis server for subscribe to a channel using a connection string:

stop(client)

Disconnect from the Redis server:

subscribe(client, channel, term)

Subscribe to a channel

Types

reconnect :: :no_reconnect | integer

max_queue :: :infinity | integer

behaviour :: :drop | :exit

start_link :: {:ok, pid} | {:error, term}

Functions

psubscribe(client, channel, term)

Specs:

  • psubscribe(pid, binary, term) :: any

Subscribe to a channel by pattern

  • psubscribe(client, "some_channel_*", fn(msg) -> ... end)
Source
start_link()
Source
start_link(host, port, password \\ "", reconnect \\ :no_reconnect, max_queue \\ :infinity, behaviour \\ :drop)

Specs:

Connect to the Redis server for subscribe to a channel

  • start_link
  • start_link("127.0.0.1", 6379)
  • start_link("127.0.0.1", 6379, "with_password")
Source
start_using_connection_string(connection_string \\ "redis://127.0.0.1:6379", reconnect \\ :no_reconnect, max_queue \\ :infinity, behaviour \\ :drop)

Specs:

Connect to the Redis server for subscribe to a channel using a connection string:

  • start_using_connection_string("redis://user:password@127.0.0.1:6379/0")
  • start_using_connection_string("redis://127.0.0.1:6379")

The database number is ignored.

Returns the pid of the connected client.

Source
stop(client)

Specs:

  • stop(pid) :: :ok

Disconnect from the Redis server:

  • stop(client)

Client is a pid getting from start command

Source
subscribe(client, channel, term)

Specs:

  • subscribe(pid, binary, term) :: any

Subscribe to a channel

  • subscribe(client, "some_channel", fn(msg) -> ... end)
Source