Features
BITFIELD and BITFIELD_RO
One particular case is represented by these two chained commands, which are
available as functions that return an instance of the BITFIELD
and,
respectively, BITFIELD_RO
classes. Use the execute
function to run the
commands.
Custom commands
If you want to run a command that hasn’t been implemented, you can use the
execute
function of your client instance and pass the command as a list
.
Encoding
Although Redis can store invalid JSON data, there might be problems with the deserialization. To avoid this, the Upstash REST proxy is capable of encoding the data as base64 on the server and then sending it to the client to be decoded.
For very large data, this can add a few milliseconds in latency. So, if you’re
sure that your data is valid JSON, you can set rest_encoding
to None
.
Retry mechanism
upstash-redis has a fallback mechanism in case of network or API issues. By
default, if a request fails it’ll retry once, 3 seconds after the error. If you
want to customize that, set rest_retries
and rest_retry_interval
(in
seconds).
Pipelines & Transactions
If you want to submit commands in batches to reduce the number of roundtrips, you can utilize pipelining or transactions. The difference between pipelines and transactions is that transactions are atomic: no other command is executed during that transaction. In pipelines there is no such guarantee.
To use a pipeline, simply call the pipeline
method:
For transaction, use mutli
:
You can also chain the commands:
Was this page helpful?