Documentation

RedisDriver
in package
implements MessageDriverInterface

FinalYes

RedisDriver using phpredis extension.

Requirements: ext-redis OR adapt to predis/predis client.

Simplified implementation:

  • queue list key: queue:{name}:list
  • message hash: queue:{name}:msg:{id}

NOTE: production implementations should handle atomic ops with LUA scripts for concurrency safety and visibility/timeouts (visibility timeout, ack).

Table of Contents

Interfaces

MessageDriverInterface
Minimal driver interface for queue backends.

Properties

$queueName  : string
$redis  : Redis

Methods

__construct()  : mixed
getMessage()  : array<string|int, mixed>|null
Return message envelope by id or null if not found.
isOnline()  : bool
Health check
listKeys()  : iterable<string|int, string>
Return iterable of message IDs (strings).
remove()  : bool
saveMessage()  : string
Save an envelope into the queue.
listKey()  : string
msgKey()  : string

Properties

Methods

__construct()

public __construct(Redis $redis[, string $queueName = 'default' ]) : mixed
Parameters
$redis : Redis
$queueName : string = 'default'

getMessage()

Return message envelope by id or null if not found.

public getMessage(string $key) : array<string|int, mixed>|null

Envelope is an associative array with keys:

  • id: string
  • class: string (task class)
  • body: mixed (serialized payload)
  • attempts: int
  • available_at: int (unix ts ms)
  • created_at: int (unix ts ms)
  • meta: array
Parameters
$key : string
Return values
array<string|int, mixed>|null

isOnline()

Health check

public isOnline() : bool
Return values
bool

listKeys()

Return iterable of message IDs (strings).

public listKeys() : iterable<string|int, string>

Implementations may return in-queue order.

Return values
iterable<string|int, string>

remove()

public remove(string $key) : bool
Parameters
$key : string
Return values
bool

saveMessage()

Save an envelope into the queue.

public saveMessage(array<string|int, mixed> $envelope[, string $position = 'append' ]) : string
Parameters
$envelope : array<string|int, mixed>
$position : string = 'append'

'append'|'prepend'

Return values
string

saved id

listKey()

private listKey() : string
Return values
string

msgKey()

private msgKey(string $id) : string
Parameters
$id : string
Return values
string
On this page

Search results