
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
A unique FIFO queue with atomic operations built on top of Redis. Useful if you want to enqueue data without worrying about it existing multiple times in the queue.
Add this line to your application's Gemfile:
gem 'redis-unique-queue'
And then execute:
$ bundle
Or install it yourself as:
$ gem install redis-unique-queue
You can instantiate a named queue using your default Redis configuration.
q = RedisUniqueQueue.new 'jobs'
Or you can pass in your own instance of the Redis class.
q = RedisUniqueQueue.new 'jobs', Redis.new(:host => "10.0.1.1", :port => 6380, :db => 15)
A third option is to instead pass your Redis configurations.
q = RedisUniqueQueue.new 'jobs', :host => "10.0.1.1", :port => 6380, :db => 15
You can push data to the queue.
q.push "hello"
q.push "world"
q.push "hello" # the item 'hello' will only exist once in the queue since it is unique
You can push multiple items onto the queue.
q.push_multi [1,2,3]
q.push_multi 4,5,6
You can pop data from the queue.
result = q.pop
You can atomically pop multiple items from the queue.
result = q.pop_multi 3
You can also pop all items in the queue in one op.
result = q.pop_all
You can get the size of the queue.
q.size
You can read the first item in the queue.
q.front
You can read the last item in the queue.
q.back
You can see if an item exists in the queue.
q.include? "hello"
You can remove an arbitrary item from the queue. Note that it doesn't have to be the first item.
q.remove "world"
You can remove an arbitrary item from the queue by index.
q.remove_item_by_index 2
You can get all items in the queue.
q.all
You can also peek into arbitrary ranges in the queue.
q.peek 1 #read the item at index 1
q.peek 23 #read the item at index 23
q.peek 10, 5 #peek at five items starting at index 10
You can also peek into arbitrary ranges in the queue in reverse order.
q.peek_reverse 0 #read the last item in the queue
q.peek_reverse 7 #read the item at index 7 starting at the end of the queue
q.peek_reverse 2, 5 #peek at five items starting at index 2 in reverse order
The queue can be cleared of all items
q.clear
Optionally, the queue can also be set to expire (in seconds).
# expire in five minutes
q.expire 60*5
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that redis-unique-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.