Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redis
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
redis
Merge requests
!54
Issue
#3128763
:Unique queue.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3128763
:Unique queue.
issue/redis-3128763:3128763-unique-queue
into
8.x-1.x
Overview
0
Commits
1
Pipelines
1
Changes
4
Open
Rakesh Kumar Regar
requested to merge
issue/redis-3128763:3128763-unique-queue
into
8.x-1.x
1 month ago
Overview
0
Commits
1
Pipelines
1
Changes
4
Expand
Closes
#3128763
0
0
Merge request reports
Compare
8.x-1.x
8.x-1.x (HEAD)
and
latest version
latest version
5c0930a0
1 commit,
1 month ago
4 files
+
61
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
src/Queue/UniquePhpRedis.php
0 → 100644
+
36
−
0
Options
<?php
namespace
Drupal\redis\Queue
;
/**
* Unique Redis queue implementation using PhpRedis extension backend.
*
* @ingroup queue
*/
class
UniquePhpRedis
extends
PhpRedis
{
/**
* {@inheritdoc}
*/
public
function
createItem
(
$data
)
{
$record
=
new
\stdClass
();
$record
->
data
=
$data
;
$record
->
qid
=
md5
(
serialize
(
$data
));
// We cannot rely on REQUEST_TIME because many items might be created
// by a single request which takes longer than 1 second.
$record
->
timestamp
=
time
();
if
(
!
$this
->
client
->
hsetnx
(
$this
->
availableItems
,
$record
->
qid
,
serialize
(
$record
)))
{
return
FALSE
;
}
$start_len
=
$this
->
client
->
lLen
(
$this
->
availableListKey
);
if
(
$start_len
<
$this
->
client
->
lpush
(
$this
->
availableListKey
,
$record
->
qid
))
{
return
$record
->
qid
;
}
return
FALSE
;
}
}
Loading