redis-queue
Version, currently 0.1.12 versions
- 0.1.1latestMay 11, 2019
- 0.1.0not indexedMay 11, 2019
github.com/parruda/redis-queue.cr
Crystal implementation of the reliable queue pattern using Redis
1 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
redis-queue:
github: parruda/redis-queue.cr
version: ~> 0.1.1Then run:
shards installshard.yml
- Crystal
0.27.0- License
- MIT
- Author
- Paulo Arruda
Dependencies
Runtime Dependencies
- redis~> 2.1.1github: stefanwille/crystal-redis
README
redis-queue.cr
Based on the Ruby version: https://github.com/taganaka/redis-queue
Adds Redis::Queue class which can be used as Distributed-Queue based on Redis. Redis is often used as a messaging server to implement processing of background jobs or other kinds of messaging tasks. It implements Reliable-queue pattern decribed here: http://redis.io/commands/rpoplpush.
Installation
- Add the dependency to your
shard.yml:
dependencies:
redis-queue:
github: parruda/redis-queue.cr
- Run
shards install
Usage
require "redis-queue"
redis = Redis.new
queue = Redis::Queue.new('q_test','bp_q_test', :redis => redis)
# Adding some elements
queue.push "a"
queue.push "b"
# Process messages
# By default, calling pop method is a blocking operation
# Your code will wait here for a new message
while message=queue.pop
# Remove message from the backup queue if the message has been processed without errors
queue.commit if YourTask.new(message).perform.succeed?
end
# Process messages using block
queue.process(force_commit: false) do |message|
# queue.commit is called if last statement of the block returns true
# or force_commit = true
YourTask.new(message).perform.succeed?
end
# Process messages with timeout (starting from version 0.0.3)
# Wait for 15 seconds for new messages, then exit
queue.process(force_commit: false, timeout: 15) do |message|
puts "'#{message}'"
end
# Process messages in a non blocking-way
# A soon as the queue is empty, the block will exit
queue.process(blocking: false) do |message|
puts "'#{message}'"
end
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/your-github-user/redis-queue/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Paulo Arruda - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.1- Tagged
- May 11, 2019
- Commit
23bbcac6c439- Crystal
0.27.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/parruda/redis-queue.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 2