Skip to content
Martin walk edited this page Dec 2, 2018 · 7 revisions

push(values)

param values

  • As to queue/stack. the parameter should be a str or an int when intend to push single member, otherwise it should be a list or a tuple.

  • As to priority queue, the parameter should be a dict which holds one or more members. In the dict, the key is member and the value is score of the member. Notice that, the score should be an int.

return value

The length of the queue

pop(count=1)

param count

Indicate how many members to pop

return value

  • As to queue/stack, the return value is a list whose length is less then or equal count.

  • As to priority queue, the return value is a list composed of tuples and each tuple holds a (member, score) pair.

push_ni(member)

Compatible with queue/stack.

The member would be pushed into the queue only if it was not already inside.

push_ni(member, score)

Compatible with priority queue.

The member would be pushed into the queue only if it was not already inside.

indexofone(member)

Getting the index of the member from queue.

return value

  • As to queue/stack/deque, it return the index of the member with 0-base. If the member not found, None would be returned.

  • As to priority queue, it return the rank of the member with 0-base. If the member not found, None would be returned.

indexofmany(members)

param members

Should be a list or a tuple.

return value

A dict whose keys are members and values are their indexes.

range(start, end)

params start and end

  • As to queue/stack/deque, start and end should be compatible with Redis::LRANGE

  • As to priority queue, start and end should be compatible with Redis::ZRANGE

return value

  • As to queue/stack/deque, a list composed of members.

  • As to prority queue, a list composed of tuples and each tuple holds a (member, score) pair.

length()

Return the length of the queue.

destruct

Destruct the queue and the Redis item would be deleted.

Clone this wiki locally