Code Documentation

Module

Redis Client for embedded python environments

class uredis_modular.list.List(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

Redis Client with support for all Redis List operations

blpop(*keys, **kwargs)[source]

Remove and get the first element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpop(*keys, **kwargs)[source]

Remove and get the last element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpoplpush(src, dst, timeout=0)[source]

Remove and get the last element of a list and push it to the front of another list, blocking if there is no value to available.

Parameters:
  • src (str) – Key to pop the value from
  • dst (str) – Key to prepend the value to
  • timeout (int, optional) – Maximum time to block waiting for a key, if not specified or the value is 0, will wait forever.
Returns:

The bytestring of the value retrievied from the src

Return type:

bytes

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
rpop(name)[source]

Remove and get the last element of a list

Parameters:name (str) – Key to pop the value from
Returns:The bytestring of the value retrievied from the src
Return type:bytes
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis.Redis() Class

class uredis.Redis(host=None, port=6379, password=None)[source]

Bases: uredis_modular.connection.Connection, uredis_modular.geo.Geo, uredis_modular.hash.Hash, uredis_modular.key.Key, uredis_modular.list.List, uredis_modular.pubsub.PubSub, uredis_modular.set.Set, uredis_modular.sortedset.SortedSet, uredis_modular.string.String

Primary Redis Client Class.

This class provides a Redis Client with all the functionality of the supported subclasses.

This class is intended to be mostly compatible with the redis-py redis.Redis()/redis.StrictRedis() classes.

auth(password)

Authenticate to the server

Parameters:password (str) – The password to authenticate with
blpop(*keys, **kwargs)

Remove and get the first element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpop(*keys, **kwargs)

Remove and get the last element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpoplpush(src, dst, timeout=0)

Remove and get the last element of a list and push it to the front of another list, blocking if there is no value to available.

Parameters:
  • src (str) – Key to pop the value from
  • dst (str) – Key to prepend the value to
  • timeout (int, optional) – Maximum time to block waiting for a key, if not specified or the value is 0, will wait forever.
Returns:

The bytestring of the value retrievied from the src

Return type:

bytes

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
echo(*args)

Echo the given string

Parameters:message (str) – The string to echo
geoadd(*args)

Add one or more geospatial items in the geospatial index represented using a sorted set

Parameters:*args – key longitude latitude member [longitude latitude member ...]
Returns:The number of elements added to the sorted set, not including elements already existing for which the score was updated.
Return type:int
geodist(*args)

Returns the distance between two members of a geospatial index

Parameters:*args – key member1 member2 [unit]
geohash(*args)

Members of a geospatial index as geohash strings

Parameters:*args – key member [member ...]
Returns:Returns members of a geospatial index as standard geohash strings
Return type:dict
geopos(*args)

Return longitude and latitude of members of a geospatial index

Parameters:*args – key member [key member ...]
Returns:Returns members of a geospatial index as standard geohash strings
Return type:dict
georadius(*args)

Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point

Parameters:*args – key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
georadiusbymember(*args)

Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member

Parameters:*args – key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
hgetall(*args)

” Returns all fields and values of the hash stored at key.

Returns:Dictionary of all key/values from the field
Return type:dict
hincrby(key, field, increment)

Increments the number stored at field in the hash stored at key by increment. If key does not exist, a new key holding a hash is created. If field does not exist the value is set to 0 before the operation is performed.

The range of values supported by HINCRBY is limited to 64 bit signed integers.

Parameters:
  • key (str) – Hash key to increment
  • field (str) – Hash field to increment
  • increment (int) – Amount to increment
Returns:

The value at field after the increment operation.

Return type:

int

ping(*args)

Ping the server

quit(*args)

Close the connection

rpop(name)

Remove and get the last element of a list

Parameters:name (str) – Key to pop the value from
Returns:The bytestring of the value retrievied from the src
Return type:bytes
select(*args)

Change the selected database

Parameters:index (int) – The redis database number to switch to
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes
zadd(name, *args, **kwargs)

Set any number of score, element-name pairs to the key name. Pairs can be specified in two ways:

As *args, in the form of: score1, name1, score2, name2

Parameters:
  • name (str) – Keyname of the list
  • *args – Sequency of name,score values

uredis.StrictRedis() Class

class uredis.StrictRedis(host=None, port=6379, password=None)[source]

Bases: uredis.uredis.Redis

auth(password)

Authenticate to the server

Parameters:password (str) – The password to authenticate with
blpop(*keys, **kwargs)

Remove and get the first element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpop(*keys, **kwargs)

Remove and get the last element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpoplpush(src, dst, timeout=0)

Remove and get the last element of a list and push it to the front of another list, blocking if there is no value to available.

Parameters:
  • src (str) – Key to pop the value from
  • dst (str) – Key to prepend the value to
  • timeout (int, optional) – Maximum time to block waiting for a key, if not specified or the value is 0, will wait forever.
Returns:

The bytestring of the value retrievied from the src

Return type:

bytes

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
echo(*args)

Echo the given string

Parameters:message (str) – The string to echo
geoadd(*args)

Add one or more geospatial items in the geospatial index represented using a sorted set

Parameters:*args – key longitude latitude member [longitude latitude member ...]
Returns:The number of elements added to the sorted set, not including elements already existing for which the score was updated.
Return type:int
geodist(*args)

Returns the distance between two members of a geospatial index

Parameters:*args – key member1 member2 [unit]
geohash(*args)

Members of a geospatial index as geohash strings

Parameters:*args – key member [member ...]
Returns:Returns members of a geospatial index as standard geohash strings
Return type:dict
geopos(*args)

Return longitude and latitude of members of a geospatial index

Parameters:*args – key member [key member ...]
Returns:Returns members of a geospatial index as standard geohash strings
Return type:dict
georadius(*args)

Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point

Parameters:*args – key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
georadiusbymember(*args)

Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member

Parameters:*args – key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
hgetall(*args)

” Returns all fields and values of the hash stored at key.

Returns:Dictionary of all key/values from the field
Return type:dict
hincrby(key, field, increment)

Increments the number stored at field in the hash stored at key by increment. If key does not exist, a new key holding a hash is created. If field does not exist the value is set to 0 before the operation is performed.

The range of values supported by HINCRBY is limited to 64 bit signed integers.

Parameters:
  • key (str) – Hash key to increment
  • field (str) – Hash field to increment
  • increment (int) – Amount to increment
Returns:

The value at field after the increment operation.

Return type:

int

ping(*args)

Ping the server

quit(*args)

Close the connection

rpop(name)

Remove and get the last element of a list

Parameters:name (str) – Key to pop the value from
Returns:The bytestring of the value retrievied from the src
Return type:bytes
select(*args)

Change the selected database

Parameters:index (int) – The redis database number to switch to
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes
zadd(name, *args, **kwargs)

Set any number of score, element-name pairs to the key name. Pairs can be specified in two ways:

As *args, in the form of: score1, name1, score2, name2

Parameters:
  • name (str) – Keyname of the list
  • *args – Sequency of name,score values

uredis_modular.connection.Connection() Class

class uredis_modular.connection.Connection(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

auth(password)[source]

Authenticate to the server

Parameters:password (str) – The password to authenticate with
convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
echo(*args)[source]

Echo the given string

Parameters:message (str) – The string to echo
ping(*args)[source]

Ping the server

quit(*args)[source]

Close the connection

select(*args)[source]

Change the selected database

Parameters:index (int) – The redis database number to switch to
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.geo.Geo() Class

class uredis_modular.geo.Geo(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
geoadd(*args)[source]

Add one or more geospatial items in the geospatial index represented using a sorted set

Parameters:*args – key longitude latitude member [longitude latitude member ...]
Returns:The number of elements added to the sorted set, not including elements already existing for which the score was updated.
Return type:int
geodist(*args)[source]

Returns the distance between two members of a geospatial index

Parameters:*args – key member1 member2 [unit]
geohash(*args)[source]

Members of a geospatial index as geohash strings

Parameters:*args – key member [member ...]
Returns:Returns members of a geospatial index as standard geohash strings
Return type:dict
geopos(*args)[source]

Return longitude and latitude of members of a geospatial index

Parameters:*args – key member [key member ...]
Returns:Returns members of a geospatial index as standard geohash strings
Return type:dict
georadius(*args)[source]

Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point

Parameters:*args – key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
georadiusbymember(*args)[source]

Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member

Parameters:*args – key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.hash.Hash() Class

class uredis_modular.hash.Hash(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
hgetall(*args)[source]

” Returns all fields and values of the hash stored at key.

Returns:Dictionary of all key/values from the field
Return type:dict
hincrby(key, field, increment)[source]

Increments the number stored at field in the hash stored at key by increment. If key does not exist, a new key holding a hash is created. If field does not exist the value is set to 0 before the operation is performed.

The range of values supported by HINCRBY is limited to 64 bit signed integers.

Parameters:
  • key (str) – Hash key to increment
  • field (str) – Hash field to increment
  • increment (int) – Amount to increment
Returns:

The value at field after the increment operation.

Return type:

int

send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.hyperloglog.HyperLogLog() Class

uredis_modular.key.Key() Class

class uredis_modular.key.Key(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.list.List() Class

class uredis_modular.list.List(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

Redis Client with support for all Redis List operations

blpop(*keys, **kwargs)[source]

Remove and get the first element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpop(*keys, **kwargs)[source]

Remove and get the last element of a list or block until one is available

Parameters:
  • *keys – Key or keys to get the first element from
  • timeout (int, optional) – Maximum time to block waiting for the key, if not specified will wait forever.
Returns:

Return type:

First element from the list, or None

brpoplpush(src, dst, timeout=0)[source]

Remove and get the last element of a list and push it to the front of another list, blocking if there is no value to available.

Parameters:
  • src (str) – Key to pop the value from
  • dst (str) – Key to prepend the value to
  • timeout (int, optional) – Maximum time to block waiting for a key, if not specified or the value is 0, will wait forever.
Returns:

The bytestring of the value retrievied from the src

Return type:

bytes

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
rpop(name)[source]

Remove and get the last element of a list

Parameters:name (str) – Key to pop the value from
Returns:The bytestring of the value retrievied from the src
Return type:bytes
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.pubsub.PubSub() Class

class uredis_modular.pubsub.PubSub(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.server.Server() Class

uredis_modular.set.Set() Class

class uredis_modular.set.Set(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.sortedset.SortedSet() Class

class uredis_modular.sortedset.SortedSet(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes
zadd(name, *args, **kwargs)[source]

Set any number of score, element-name pairs to the key name. Pairs can be specified in two ways:

As *args, in the form of: score1, name1, score2, name2

Parameters:
  • name (str) – Keyname of the list
  • *args – Sequency of name,score values

uredis_modular.string.String() Class

class uredis_modular.string.String(host=None, port=6379, password=None)[source]

Bases: uredis_modular.client.Client

convert_to_bytestream(value)

Return a bytestream of the value

Parameters:value
Returns:A bytestream of the value
Return type:bytes
send_redis_array_string(items)

Send a redis array string

Parameters:items (list) – The items to be in the redis array string
Returns:Redis RESP bytestream representation of the array
Return type:bytes

uredis_modular.transaction.Transaction() Class