Datatypes - redish.types

class redish.types.Dict(name, client, initial=None, **extra)

A dictionary.

get(key, default=None)
Returns the value at key if present, otherwise returns default (None by default.)
has_key(key)
Returns True if key is present in this dictionary, False otherwise.
items()
This dictionary as a list of (key, value) pairs, as 2-tuples.
iteritems()
Returns an iterator over the (key, value) items present in this dictionary.
iterkeys()
Returns an iterator over the keys present in this dictionary.
itervalues()
Returns an iterator over the values present in this dictionary.
keys()
Returns the list of keys present in this dictionary.
pop(key, default=None)

Remove specified key and return the corresponding value.

If key is not found, default is returned if given, otherwise KeyError is raised.

setdefault(key, default=None)
Returns the value at key if present, otherwise stores default value at key.
update(other)
Update this dictionary with another.
values()
Returns the list of values present in this dictionary.
redish.types.Id(name, client)
Return the next value for an unique id.
class redish.types.LifoQueue(name, client, initial=None, maxsize=0)
Variant of Queue that retrieves most recently added entries first.
class redish.types.List(name, client, initial=None)

A list.

append(value)
Add value to the end of the list.
appendleft(value)
Add value to the head of the list.
extend(iterable)
Append the values in iterable to this list.
extendleft(iterable)
Add the values in iterable to the head of this list.
pop()
Remove and return the last element of the list.
popleft()
Remove and return the first element of the list.
remove(value, count=1)

Remove occurences of value from the list.

Parameter:count – Number of matching values to remove. Default is to remove a single value.
trim(start, stop)
Trim the list to the specified range of elements.
class redish.types.Queue(name, client, initial=None, maxsize=0)

FIFO Queue.

exception Empty
Exception raised by Queue.get(block=0)/get_nowait().
exception Queue.Full
Exception raised by Queue.put(block=0)/put_nowait().
Queue.empty()
Return True if the queue is empty, or False otherwise (not reliable!).
Queue.full()

Return True if the queue is full, False otherwise (not reliable!).

Only applicable if maxsize is set.

Queue.get(block=True, timeout=None)

Remove and return an item from the queue.

If optional args block is True and timeout is None (the default), block if necessary until an item is available. If timeout is a positive number, it blocks at most timeout seconds and raises the Queue.Empty exception if no item was available within that time. Otherwise (block is False), return an item if one is immediately available, else raise the Queue.Empty exception (timeout is ignored in that case).

Queue.get_nowait()

Remove and return an item from the queue without blocking.

Raises Queue.Empty:
 if an item is not immediately available.
Queue.put(item, **kwargs)
Put an item into the queue.
Queue.qsize()
Returns the current size of the queue.
class redish.types.Set(name, client, initial=None)

A set.

add(member)

Add element to set.

This has no effect if the member is already present.

difference(other)

Return the difference of two or more sets as a new set.

(i.e. all elements that are in this set but not the others.)

difference_update(other)
Remove all elements of another set from this set.
intersection(other)

Return the intersection of two sets as a new set.

(i.e. all elements that are in both sets.)

intersection_update(other)
Update the set with the intersection of itself and another.
pop()

Remove and return an arbitrary set element.

Raises KeyError:
 if the set is empty.
remove(member)

Remove element from set; it must be a member.

Raises KeyError:
 if the element is not a member.
union(other)

Return the union of sets as a new set.

(i.e. all elements that are in either set.)

update(other)
Update this set with the union of itself and others.
class redish.types.SortedSet(name, client, initial=None)

A sorted set.

Parameter:initial – Initial data to populate the set with, must be an iterable of (element, score) tuples.
add(member, score)
Add the specified member to the sorted set, or update the score if it already exist.
increment(member, amount=1)
Increment the score of member by amount.
range_by_score(min, max)
Return all the elements with score >= min and score <= max (a range query) from the sorted set.
rank(member)
Rank the set with scores being ordered from low to high.
remove(member)
Remove member.
revrank(member)
Rank the set with scores being ordered from high to low.
score(member)
Return the score associated with the specified member.
class redish.types.Type(name, client)
Base-class for Redis datatypes.

Previous topic

Database - redish.client

Next topic

Models - redish.models

This Page