exredis v0.3.0 Exredis.Sub View Source

Subscribe functions for exredis

Link to this section Summary

Functions

Subscribe to a channel or channels by pattern

Disconnect from the Redis server

Subscribe to a channel or channels

Link to this section Types

Link to this type behaviour() View Source
behaviour() :: :drop | :exit
Link to this type max_queue() View Source
max_queue() :: :infinity | integer()
Link to this type reconnect() View Source
reconnect() :: :no_reconnect | integer()
Link to this type start_link() View Source
start_link() :: {:ok, pid()} | {:error, term()}

Link to this section Functions

Link to this function psubscribe(client, channel, term) View Source
psubscribe(pid(), binary() | [binary()], term()) :: any()

Subscribe to a channel or channels by pattern

  • psubscribe(client, "some_channel_*", fn(msg) -> ... end)
  • psubscribe(client, ["some_channel_*", "other_channel_*"], fn(msg) -> ... end)
Link to this function start_link(host, port, password \\ "", reconnect \\ :no_reconnect, max_queue \\ :infinity, behaviour \\ :drop) View Source
start_link(binary(), integer(), binary(), reconnect(), max_queue(), behaviour()) ::
  start_link()

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")
Link to this function start_using_connection_string(connection_string \\ "redis://127.0.0.1:6379", reconnect \\ :no_reconnect, max_queue \\ :infinity, behaviour \\ :drop) View Source
start_using_connection_string(binary(), reconnect(), max_queue(), behaviour()) ::
  pid()

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.

Link to this function stop(client) View Source
stop(pid()) :: :ok

Disconnect from the Redis server:

  • stop(client)

Client is a pid getting from start command

Link to this function subscribe(client, channel, term) View Source
subscribe(pid(), binary() | [binary()], term()) :: any()

Subscribe to a channel or channels

  • subscribe(client, "some_channel", fn(msg) -> ... end)
  • subscribe(client, ["some_channel", "other_channel"], fn(msg) -> ... end)