abstract class Connection mixin Redis (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected Redis $client

The Redis client.

protected string|null $name

The Redis connection name.

protected Dispatcher|null $events

The event dispatcher instance.

Methods

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Pass other method calls down to the underlying client.

void
createSubscription(array|string $channels, Closure $callback, string $method = 'subscribe')

Subscribe to a set of given channels for messages.

funnel(string $name)

Funnel a callback for a maximum number of simultaneous executions.

throttle(string $name)

Throttle a callback for a maximum number of executions over a given duration.

mixed
client()

Get the underlying Redis client.

void
subscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels for messages.

void
psubscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels with wildcards.

mixed
command(string $method, array $parameters = [])

Run a command against the Redis database.

array
parseParametersForEvent(array $parameters)

Parse the command's parameters for event dispatching.

void
event(mixed $event) deprecated

Fire the given event if possible.

void
listen(Closure $callback)

Register a Redis command listener with the connection.

void
listenForFailures(Closure $callback)

Register a Redis command failure listener with the connection.

bool
isCluster()

Determine if the connection is a cluster connection.

string|null
getName()

Get the connection name.

$this
setName(string $name)

Set the connection's name.

Dispatcher|null
getEventDispatcher()

Get the event dispatcher used by the connection.

void
setEventDispatcher(Dispatcher $events)

Set the event dispatcher instance on the connection.

void
unsetEventDispatcher()

Unset the event dispatcher instance on the connection.

static bool
hasHashTag(string $key)

Determine if the given key contains a Redis Cluster hash tag.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Pass other method calls down to the underlying client.

Parameters

string $method
array $parameters

Return Value

mixed

abstract void createSubscription(array|string $channels, Closure $callback, string $method = 'subscribe')

Subscribe to a set of given channels for messages.

Parameters

array|string $channels
Closure $callback
string $method

Return Value

void

ConcurrencyLimiterBuilder funnel(string $name)

Funnel a callback for a maximum number of simultaneous executions.

Parameters

string $name

Return Value

ConcurrencyLimiterBuilder

DurationLimiterBuilder throttle(string $name)

Throttle a callback for a maximum number of executions over a given duration.

Parameters

string $name

Return Value

DurationLimiterBuilder

mixed client()

Get the underlying Redis client.

Return Value

mixed

void subscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels for messages.

Parameters

array|string $channels
Closure $callback

Return Value

void

void psubscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels with wildcards.

Parameters

array|string $channels
Closure $callback

Return Value

void

mixed command(string $method, array $parameters = [])

Run a command against the Redis database.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

Throwable

protected array parseParametersForEvent(array $parameters)

Parse the command's parameters for event dispatching.

Parameters

array $parameters

Return Value

array

protected void event(mixed $event) deprecated

deprecated since Laravel 11.x

Fire the given event if possible.

Parameters

mixed $event

Return Value

void

void listen(Closure $callback)

Register a Redis command listener with the connection.

Parameters

Closure $callback

Return Value

void

void listenForFailures(Closure $callback)

Register a Redis command failure listener with the connection.

Parameters

Closure $callback

Return Value

void

bool isCluster()

Determine if the connection is a cluster connection.

Return Value

bool

string|null getName()

Get the connection name.

Return Value

string|null

$this setName(string $name)

Set the connection's name.

Parameters

string $name

Return Value

$this

Dispatcher|null getEventDispatcher()

Get the event dispatcher used by the connection.

Return Value

Dispatcher|null

void setEventDispatcher(Dispatcher $events)

Set the event dispatcher instance on the connection.

Parameters

Dispatcher $events

Return Value

void

void unsetEventDispatcher()

Unset the event dispatcher instance on the connection.

Return Value

void

static bool hasHashTag(string $key)

Determine if the given key contains a Redis Cluster hash tag.

Parameters

string $key

Return Value

bool

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.