Charon.SessionStore.RedisStore.RedisClient (Charon v4.2.0)

View Source

Redis client backed by a connection pool.

Summary

Functions

Execute a Redis command using any connection from Charon.SessionStore.RedisStore.ConnectionPool.

Execute a Redis command using a previously checked-out connection.

Execute a list of Redis commands using a previously checked-out connection.

Execute a list of Redis commands as a MULTI/EXEC transaction using a previously checked-out connection.

Execute a list of Redis commands using any connection from Charon.SessionStore.RedisStore.ConnectionPool.

Execute Redis' SCAN command and stream the results.

Execute a list of Redis commands as a MULTI/EXEC transaction using any connection from Charon.SessionStore.RedisStore.ConnectionPool.

Types

command()

@type command() :: Redix.command()

connection()

@type connection() :: Redix.connection()

redix_result()

@type redix_result() ::
  {:ok, Redix.Protocol.redis_value()}
  | {:error, atom() | Redix.Error.t() | Redix.ConnectionError.t()}

Functions

command(command, debug_log? \\ false, redix_opts \\ [])

@spec command(command(), boolean(), keyword()) :: redix_result()

Execute a Redis command using any connection from Charon.SessionStore.RedisStore.ConnectionPool.

conn_command(command, conn, debug_log? \\ false, redix_opts \\ [])

@spec conn_command(command(), connection(), boolean(), keyword()) :: redix_result()

Execute a Redis command using a previously checked-out connection.

Either use this command with the connection available inside Charon.SessionStore.RedisStore.ConnectionPool.transaction/2, or use Charon.SessionStore.RedisStore.ConnectionPool.checkout/2 to get a connection, combined with Charon.SessionStore.RedisStore.ConnectionPool.checkin/1 to return the connection to the pool.

conn_pipeline(commands, conn, debug_log? \\ false, redix_opts \\ [])

@spec conn_pipeline([command()], connection(), boolean(), keyword()) :: redix_result()

Execute a list of Redis commands using a previously checked-out connection.

Either use this command with the connection available inside Charon.SessionStore.RedisStore.ConnectionPool.transaction/2, or use Charon.SessionStore.RedisStore.ConnectionPool.checkout/2 to get a connection, combined with Charon.SessionStore.RedisStore.ConnectionPool.checkin/1 to return the connection to the pool.

conn_transaction_pipeline(commands, conn, debug_log? \\ false, redix_opts \\ [])

(since 4.0.0)
@spec conn_transaction_pipeline([command()], connection(), boolean(), keyword()) ::
  redix_result()

Execute a list of Redis commands as a MULTI/EXEC transaction using a previously checked-out connection.

Either use this command with the connection available inside Charon.SessionStore.RedisStore.ConnectionPool.transaction/2, or use Charon.SessionStore.RedisStore.ConnectionPool.checkout/2 to get a connection, combined with Charon.SessionStore.RedisStore.ConnectionPool.checkin/1 to return the connection to the pool.

pipeline(commands, debug_log? \\ false, redix_opts \\ [])

@spec pipeline([command()], boolean(), keyword()) :: redix_result()

Execute a list of Redis commands using any connection from Charon.SessionStore.RedisStore.ConnectionPool.

stream_scan(opts \\ [])

(since 4.0.0)
@spec stream_scan(keyword()) :: Enum.t()

Execute Redis' SCAN command and stream the results.

Options :type, :count and :match can be passed in and map to the command's options. Note that using count only influences the batch size in which results are returned by Redis, and results are streamed one-by-one regardless.

Examples

iex> stream_scan(match: "myprefix.*") |> Enum.map(&Function.identity/1)
["myprefix.a", "myprefix.b"]

transaction_pipeline(commands, debug_log? \\ false, redix_opts \\ [])

(since 4.0.0)
@spec transaction_pipeline([command()], boolean(), keyword()) :: redix_result()

Execute a list of Redis commands as a MULTI/EXEC transaction using any connection from Charon.SessionStore.RedisStore.ConnectionPool.