abstract class Redis_Queue_Base in Redis 7.2
Same name and namespace in other branches
- 7.3 lib/Redis/Queue/Base.php \Redis_Queue_Base
Redis allows implementing reliable queues, here is the spec:
- For each queue, you have 4 different HASH:
- One for queued items queue:NAME:queued
- One for claimed items being processed: queue:NAME:claimed
- One for claimed items leave time: queue:NAME:leave Items from this one will be arbitrarily fetched at cron time and released when leave is outdated.
- One containing the item values and other valuable stateful information: queue:NAME:data ;
- For example, current job maximum identifier (auto increment emulation) will be stored in the "sequence" HASH key
- All other keys within the HASH will be the items themselves, keys for those will always be numeric
- Each time a queue will be emptied, even during a pragmatic process, it will be automatically deleted, reseting the sequence counter to the 0 value each time
- Algorithm is a variation of the one described in "Reliable queue" section of http://redis.io/commands/rpoplpush and partial port of what you can find in the http://drupal.org/project/redis_queue module.
You will find the driver specific implementation in the Redis_Queue_* classes as they may differ in how the API handles transaction, pipelining and return values.
Hierarchy
- class \Redis_AbstractBackend
- class \Redis_Queue_Base implements DrupalReliableQueueInterface
Expanded class hierarchy of Redis_Queue_Base
File
- lib/
Redis/ Queue/ Base.php, line 37
View source
abstract class Redis_Queue_Base extends Redis_AbstractBackend implements DrupalReliableQueueInterface {
/**
* Key prefix for queue data.
*/
const QUEUE_KEY_PREFIX = 'queue';
/**
* Data HASH sequence key name.
*/
const QUEUE_HKEY_SEQ = 'seq';
/**
* Queue name
*
* @var string
*/
protected $name;
/**
* Get data HASH key
*
* Key will already be prefixed
*
* @return string
*/
public function getKeyForData() {
return $this
->getKey(self::QUEUE_KEY_PREFIX, $this->name, 'data');
}
/**
* Get queued items LIST key
*
* Key will already be prefixed
*
* @return string
*/
public function getKeyForQueue() {
return $this
->getKey(self::QUEUE_KEY_PREFIX, $this->name, 'queued');
}
/**
* Get claimed LIST key
*
* Key will already be prefixed
*
* @return string
*/
public function getKeyForClaimed() {
return $this
->getKey(self::QUEUE_KEY_PREFIX, $this->name, 'claimed');
}
/**
* Default contructor
*
* Beware that DrupalQueueInterface does not defines the __construct
* method in the interface yet is being used from DrupalQueue::get()
*
* @param unknown $name
*/
public function __construct($name) {
$this->name = $name;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalQueueInterface:: |
public | function | Claim an item in the queue for processing. | 2 |
DrupalQueueInterface:: |
public | function | Add a queue item and store it directly to the queue. | 2 |
DrupalQueueInterface:: |
public | function | Create a queue. | 2 |
DrupalQueueInterface:: |
public | function | Delete a finished item from the queue. | 2 |
DrupalQueueInterface:: |
public | function | Delete a queue and every item in the queue. | 2 |
DrupalQueueInterface:: |
public | function | Retrieve the number of items in the queue. | 2 |
DrupalQueueInterface:: |
public | function | Release an item that the worker could not process, so another worker can come in and process it before the timeout expires. | 2 |
Redis_AbstractBackend:: |
protected static | property | ||
Redis_AbstractBackend:: |
private | property | ||
Redis_AbstractBackend:: |
public | function | Get redis client | |
Redis_AbstractBackend:: |
public static | function | Get global default prefix | |
Redis_AbstractBackend:: |
public static | function | Get site default global prefix | |
Redis_AbstractBackend:: |
public | function | Get full key name using the set prefix | 2 |
Redis_AbstractBackend:: |
final public | function | Get prefix | |
Redis_AbstractBackend:: |
constant | Key components name separator | ||
Redis_AbstractBackend:: |
final public | function | Set prefix | |
Redis_Queue_Base:: |
protected | property | Queue name | |
Redis_Queue_Base:: |
public | function | Get claimed LIST key | |
Redis_Queue_Base:: |
public | function | Get data HASH key | |
Redis_Queue_Base:: |
public | function | Get queued items LIST key | |
Redis_Queue_Base:: |
constant | Data HASH sequence key name. | ||
Redis_Queue_Base:: |
constant | Key prefix for queue data. | ||
Redis_Queue_Base:: |
public | function |
Default contructor Overrides Redis_AbstractBackend:: |