redis_unique_queue v0.1.1 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

all(queue)

Specs

all(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}) :: {atom, []}

Get all items in the queue

Examples

iex(14)> RedisUniqueQueue.all(queue)
{:ok, ["test2", "test3"]}
back(queue)

Specs

back(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}) :: {atom, []}

Read the last item in the queue

Examples

iex(5)> RedisUniqueQueue.back(queue)
{:ok, ["test3"]}
clear(queue)

Specs

clear(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}) :: {}

The queue can be cleared of all items

Examples

iex(14)> RedisUniqueQueue.clear(queue)
{:ok, 1}
create(name, options)

Specs

create(name :: String.t, options :: %{host: String.t, port: port}) :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}
create(name :: String.t, conn :: pid) :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}

Queue creation

Examples

  • with options(redis host and port)

    iex> queue = RedisUniqueQueue.create("test_queue", %{host: "0.0.0.0", port: 6379})
    %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> queue = RedisUniqueQueue.create("test_queue", conn)
    %RedisUniqueQueue.UniqueQueue{conn: #PID<0.163.0>, name: "test_queue", options: %{}}
expire(queue, seconds)

Specs

expire(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}, seconds :: pos_integer) :: {}

Optionally, the queue can also be set to expire (in seconds).

Examples

iex(14)> RedisUniqueQueue.expire(queue, 30)
{:ok, 1}
front(queue)

Specs

front(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}) :: {atom, []}

Read the first item in the queue

Examples

iex(5)> RedisUniqueQueue.front(queue)
{:ok, ["test2"]}
include?(queue, data)

Specs

include?(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: 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}
peek(queue, from, amount)

Specs

peek(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: 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"]}
pop(queue)

Specs

pop(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}) :: {atom, []}

Pop data from the queue

Examples

iex(5)> RedisUniqueQueue.pop(queue)
{:ok, ["test"]}
pop_all(queue)

Specs

pop_all(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}) :: {atom, []}

Pop all items in the queue

Examples

iex(5)> RedisUniqueQueue.pop_all(queue)
{:ok, ["test2", "test3"]}
pop_multi(queue, amount)

Specs

pop_multi(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}, amount :: non_neg_integer) :: {atom, []}

Atomically pop multiple items from the queue

Examples

iex(5)> RedisUniqueQueue.pop_multi(queue, 2)
{:ok, ["test2", "test3"]}
push(queue, data)

Specs

push(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}, data :: String.Chars.t) :: {}

Push data to the queue

Examples

iex(2)> RedisUniqueQueue.push(queue, "test")
{:ok, 1}
push_multi(queue, value)

Specs

push_multi(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}, data :: String.Chars.t) :: {}

Push multiple items onto the queue

Examples

iex(3)> RedisUniqueQueue.push_multi(queue, ["test2", "test3"])
{:ok, 2}
remove(queue, data)

Specs

remove(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}, value :: String.Chars.t) :: {}

Remove an arbitrary item from the queue

Examples

iex(12)> RedisUniqueQueue.remove(queue, ["test","test3"])
{:ok, 2}
remove_item_by_index(queue, index)

Remove an arbitrary item from the queue by index

Examples

iex(14)> RedisUniqueQueue.remove_item_by_index(queue, 2)
{:ok, 1}
size(queue)

Specs

size(queue :: %RedisUniqueQueue.UniqueQueue{conn: term, name: term, options: term}) :: {atom, non_neg_integer}

Get the size of the queue

Examples

iex(14)> RedisUniqueQueue.size(queue)
{:ok, 4}