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

push(values)

param values

  • 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.
  • 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

  • queue/stack/priority queue: length of the queue
  • capped queue/stack/priority queue: error code if the queue was full or lacked of positions, else length of the queue
  • overflow-able capped queue: a list like [length, [m1, m2]] contains length of the queue and the members been pushed out.
  • overflow-able capped priority queue: a list like [length, [(m1,s1),(m2,s2)]] contains length of the queue and the overflowed members been pushed out with their scores.

pop(count=1)

param count

How many members to pop

return value

  • queue/stack: a list contains the members been pop.

  • priority queue: a list composed of tuples and each tuple holds a (member, score) pair.

push_front(values)

  • deque: same to queue/stack except that the members are pushed into from the front end.
  • capped deque: same to capped queue except that the members are pushed into from the front end.
  • overflow-able capped deque: same to overflow-able capped queue except that the members are pushed into from the front end and the overflowed members are pushed out from the back end.

push_back(values)

  • deque: same to queue/stack
  • capped deque: same to capped queue
  • overflow-able capped deque: same to overflow-able capped queue

push_ni(member)

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

  • queue/stack: a list like [int, bool] contains length of queue and a bool which indicates the member been pushed into or not.
  • capped queue/stack: error code if the queue was full or lacked of positions, otherwise the same to queue/stack.
  • overflow-able queue: a list like [int, list, bool], similar to push of overflow-able queue except that the bool indicates the member been pushed into or not.

push_ni(member, score)

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

  • priority queue: a list like [int, bool] contains length of queue and a flag which indicates the member been pushed into or not.
  • capped priority queue: error code if the queue was full or lacked of positions, otherwise the same to priority queue.
  • overflow-able priority queue: a list like [int, list, bool], similar to push of overflow-able priority queue except that the bool indicates the member been pushed into or not.

indexofone(member)

Getting the index of the member.

return value

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

  • priority queue: 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

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

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

return value

  • queue/stack/deque: a list composed of members.

  • 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.

expire, expireat, pexpire, pexpireat, ttl, pttl

The parameter(s) would be passed transparently to Redis client behind the scene.