redis_unique_queue v0.1.5 RedisUniqueQueue
Is the elixir-implementation of ruby-gem ruby-redis-unique-queue
Summary
Functions
Get all items in the queue
Read the last item in the queue
The queue can be cleared of all items
Queue creation
Optionally, the queue can also be set to expire (in seconds)
Read the first item in the queue
See if an item exists in the queue
Peek into arbitrary ranges in the queue
Pop data from the queue
Pop all items in the queue
Atomically pop multiple items from the queue
Push data to the queue
Push multiple items onto the queue
Remove an arbitrary item from the queue
Remove an arbitrary item from the queue by index
Get the size of the queue
Functions
Specs
all(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}) :: {atom, []}
Get all items in the queue
Examples
iex(14)> RedisUniqueQueue.all(queue)
{:ok, ["test2", "test3"]}
Specs
back(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}) :: {atom, []}
Read the last item in the queue
Examples
iex(5)> RedisUniqueQueue.back(queue)
{:ok, ["test3"]}
Specs
clear(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}) :: {}
The queue can be cleared of all items
Examples
iex(14)> RedisUniqueQueue.clear(queue)
{:ok, 1}
Specs
Queue creation
Examples
with options(redis host and port)
iex> {:ok, queue} = RedisUniqueQueue.create("test_queue", %{host: "0.0.0.0", port: 6379}) {:ok, %RedisUniqueQueue.UniqueQueue{conn: #PID<0.177.0>, name: "test_queue", options: %{host: "0.0.0.0", port: 6379}}}
with Redix connection
iex> {:ok, conn} = Redix.start_link(host: "0.0.0.0", port: 6379) {:ok, #PID<0.163.0>} iex> {:ok, queue} = RedisUniqueQueue.create("test_queue", conn) {:ok, %RedisUniqueQueue.UniqueQueue{conn: #PID<0.163.0>, name: "test_queue", options: %{}}}
Specs
expire(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}, seconds :: pos_integer) :: {}
Optionally, the queue can also be set to expire (in seconds).
Examples
iex(14)> RedisUniqueQueue.expire(queue, 30)
{:ok, 1}
Specs
front(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}) :: {atom, []}
Read the first item in the queue
Examples
iex(5)> RedisUniqueQueue.front(queue)
{:ok, ["test2"]}
Specs
include?(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}, value :: String.Chars.t) :: {atom, boolean}
See if an item exists in the queue
Examples
iex(14)> RedisUniqueQueue.include?(queue, "test")
{:ok, true}
iex(15)> RedisUniqueQueue.include?(queue, "test44")
{:ok, false}
Specs
peek(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}, from :: non_neg_integer, amount :: non_neg_integer) :: {atom, []}
Peek into arbitrary ranges in the queue
Examples
iex(14)> RedisUniqueQueue.peek(queue, 1, 2)
{:ok, ["test2", "test3"]}
Specs
pop(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}) :: {atom, []}
Pop data from the queue
Examples
iex(5)> RedisUniqueQueue.pop(queue)
{:ok, ["test"]}
Specs
pop_all(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}) :: {atom, []}
Pop all items in the queue
Examples
iex(5)> RedisUniqueQueue.pop_all(queue)
{:ok, ["test2", "test3"]}
Specs
pop_multi(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}, amount :: non_neg_integer) :: {atom, []}
Atomically pop multiple items from the queue
Examples
iex(5)> RedisUniqueQueue.pop_multi(queue, 2)
{:ok, ["test2", "test3"]}
Specs
push(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}, data :: String.Chars.t) :: {}
Push data to the queue
Examples
iex(2)> RedisUniqueQueue.push(queue, "test")
{:ok, 1}
Specs
push_multi(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}, data :: String.Chars.t) :: {}
Push multiple items onto the queue
Examples
iex(3)> RedisUniqueQueue.push_multi(queue, ["test2", "test3"])
{:ok, 2}
Specs
remove(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term, scripts: term}, value :: String.Chars.t) :: {}
Remove an arbitrary item from the queue
Examples
iex(12)> RedisUniqueQueue.remove(queue, ["test","test3"])
{:ok, 2}
Remove an arbitrary item from the queue by index
Examples
iex(14)> RedisUniqueQueue.remove_item_by_index(queue, 2)
{:ok, 1}