View Source SuperCache.Queue (SuperCache v0.6.1)

A queue based on cache. Data in queue stored in cache. Can handle multiple queue with different name. A queue is a FIFO data structure. This is global data, any process can access to queue data. Need to start SuperCache.start!/1 before using this module. Ex:

alias SuperCache.Queue
SuperCache.start!()
Queue.add("my_queue", "Hello")
Queue.out("my_queue")
  # => "Hello"

Summary

Functions

Add value to queue with name is queue_name. Queue is a FIFO data structure. If queue_name is not existed, it will be created.

Count number of data in queue with name is queue_name. If queue_name is not existed, it will return 0.

Get all items in queue. If queue_name is not existed, it will return []. If queue is empty, it will return [].

Pop value from queue with name is queue_name. If queue_name is not existed or no data, it will return default value.

Peak value from queue with name is queue_name. Data still in queue after peak. If queue_name is not existed or no data, it will return default value.

Functions

add(queue_name, value)

@spec add(any(), any()) :: true

Add value to queue with name is queue_name. Queue is a FIFO data structure. If queue_name is not existed, it will be created.

count(queue_name)

@spec count(any()) :: number()

Count number of data in queue with name is queue_name. If queue_name is not existed, it will return 0.

get_all(queue_name)

@spec get_all(any()) :: list()

Get all items in queue. If queue_name is not existed, it will return []. If queue is empty, it will return [].

out(queue_name, default \\ nil)

@spec out(any(), any()) :: any()

Pop value from queue with name is queue_name. If queue_name is not existed or no data, it will return default value.

peak(queue_name, default \\ nil)

@spec peak(any(), any()) :: any()

Peak value from queue with name is queue_name. Data still in queue after peak. If queue_name is not existed or no data, it will return default value.