objects¶
-
class
async_redis_objects.objects.
Set
(key, client)¶ Interface to a redis set.
Can be constructed directly, or from an
ObjectClient
factory.- Parameters
key (
str
) – key in the redis server that is empty, or pointing to an existing setclient (
Redis
) –
-
async
add
(*values)¶ Add one or more values to the set.
- Parameters
values – All arguments are treated as items to add.
- Return type
int
- Returns
Number of items added to the set
-
async
has
(value)¶ Test if a value is in the set already
- Parameters
value – Possible value within the set.
- Returns
boolean, true if value is in set.
-
async
all
()¶ Load the entire set.
- Return type
Set
[Any
]
-
async
size
()¶ Get the number of items in the set.
- Return type
int
-
async
remove
(value)¶ Remove value from the set
- Parameters
value – Possible value in the set.
- Return type
bool
- Returns
True if the field was removed.
-
async
clear
()¶ Clear all values in the set.
Removes the top level key from the redis database.
-
class
async_redis_objects.objects.
Hash
(key, client)¶ Interface to a redis hash.
Can be constructed directly, or from an
ObjectClient
factory.- Parameters
key (
str
) – key in the redis server that is empty, or pointing to an existing hashclient (
Redis
) –
-
async
set
(key, value)¶ Set the value of a field in the hash.
- Parameters
key (
str
) – Key within the hash table.value – Unserialized value to write to the hash table.
- Return type
bool
- Returns
True if the key is new.
-
async
add
(key, value)¶ Add a field to the hash table.
If a field with that key already exists, this operation does nothing.
- Parameters
key (
str
) – Key within the hash table.value – Unserialized value to write to the hash table.
- Return type
bool
- Returns
True if the value has been inserted.
-
async
get
(key)¶ Read a field from the hash.
- Parameters
key (
str
) – Possible key within the hash table.- Returns
Value if found, None otherwise.
-
async
mget
(keys)¶ Read a set of fields from the hash.
- Parameters
keys (
Iterable
[str
]) – Sequence of potential keys to load from the hash.- Return type
Dict
[str
,Any
]
-
async
all
()¶ Load the entire hash as a dict.
- Return type
Dict
[str
,Any
]
-
async
keys
()¶ Read all the keys in the hash.
- Return type
Set
[str
]
-
async
size
()¶ Get the number of items in the hash table.
- Return type
int
-
async
delete
(key)¶ Remove a field from the hash.
- Parameters
key – Possible key within the hash table.
- Return type
bool
- Returns
True if the field was removed.
-
async
clear
()¶ Clear all values in the hash.
Removes the top level key from the redis database.
-
class
async_redis_objects.objects.
Queue
(key, client)¶ A queue interface to a redis list.
Can be constructed directly, or from an
ObjectClient
factory.-
async
push
(data)¶ Push an item to the queue.
- Parameters
data – Item to push into queue.
-
async
pop
(timeout=1)¶ Pop an item from the front of the queue.
- Parameters
timeout (
int
) – Maximum time to wait for an item to become available in seconds.- Return type
Any
-
async
pop_ready
()¶ Pop an item from the front of the queue if it is immediately available.
- Return type
Any
-
async
clear
()¶ Drop all items from the queue.
-
async
length
()¶ Number of items in the queue.
-
async
-
class
async_redis_objects.objects.
PriorityQueue
(key, client)¶ A priority queue interface to a redis sorted set.
Can be constructed directly, or from an
ObjectClient
factory.-
async
push
(data, priority=0)¶ Push an item to the queue.
If data is already in the queue, reset its priority.
- Parameters
data – Item to push into queue.
priority – Sorting priority within the queue.
-
async
pop
(timeout=1)¶ Pop the highest priority item from the queue.
- Parameters
timeout (
int
) – Maximum time to wait in seconds for an item to become available.- Return type
Any
-
async
pop_ready
()¶ Pop the highest priority item from the queue if one is available immediately.
- Return type
Any
-
async
clear
()¶ Drop all items from the queue.
-
async
score
(item)¶ Get the current priority of item.
-
async
rank
(item)¶ Get the distance of item from the front of the queue.
-
async
length
()¶ Number of items in the queue.
-
async
-
class
async_redis_objects.objects.
LockContext
(name, client, max_duration, timeout)¶
-
class
async_redis_objects.objects.
ObjectClient
(redis_client)¶ A client object to represent a redis server.
Can be used as a factory to access data structures in the server as python objects.
-
priority_queue
(name)¶ Load a stateful-set to be used as a priority queue.
- Return type
-
lock
(name, max_duration=60, timeout=None)¶ A redis resident lock to create mutex blocks across devices.
- Parameters
name (
str
) – A unique identifier for the lockmax_duration (
int
) – Max time to hold the lock in secondstimeout (
Optional
[int
]) – Max time to wait to acquire the mutex
- Returns
-