-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sfcod/redis
Redis
- Loading branch information
Showing
38 changed files
with
1,028 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace SfCod\QueueBundle\Base; | ||
|
||
/** | ||
* Trait RandomizeTrait | ||
* | ||
* @package SfCod\QueueBundle\Base | ||
*/ | ||
trait RandomizeTrait | ||
{ | ||
/** | ||
* Get a random ID string. | ||
* | ||
* @return string | ||
* | ||
* @throws \Exception | ||
*/ | ||
private function getRandomId(): string | ||
{ | ||
return bin2hex(random_bytes(12)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace SfCod\QueueBundle\Connector; | ||
|
||
use SfCod\QueueBundle\Base\JobResolverInterface; | ||
use SfCod\QueueBundle\Queue\QueueInterface; | ||
use SfCod\QueueBundle\Queue\RedisQueue; | ||
use SfCod\QueueBundle\Service\RedisDriver; | ||
|
||
/** | ||
* Connector for queue to redis | ||
* | ||
* @author Virchenko Maksim <muslim1992@gmail.com> | ||
*/ | ||
class RedisConnector implements ConnectorInterface | ||
{ | ||
/** | ||
* @var JobResolverInterface | ||
*/ | ||
protected $jobResolver; | ||
|
||
/** | ||
* @var RedisDriver | ||
*/ | ||
protected $redis; | ||
|
||
/** | ||
* RedisConnector constructor. | ||
* | ||
* @param JobResolverInterface $jobResolver | ||
* @param RedisDriver $redis | ||
*/ | ||
public function __construct(JobResolverInterface $jobResolver, RedisDriver $redis) | ||
{ | ||
$this->jobResolver = $jobResolver; | ||
$this->redis = $redis; | ||
} | ||
|
||
/** | ||
* Establish a queue database. | ||
* | ||
* @param array $config | ||
* | ||
* @return QueueInterface | ||
*/ | ||
public function connect(array $config): QueueInterface | ||
{ | ||
$config = array_merge([ | ||
'limit' => 15, | ||
], $config); | ||
|
||
return new RedisQueue( | ||
$this->jobResolver, | ||
$this->redis, | ||
$config['collection'], | ||
$config['queue'], | ||
$config['expire'], | ||
$config['limit'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.