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.

redis.bitfield("test_key") \
  .incrby(encoding="i8", offset=100, increment=100) \
  .overflow("SAT") \
  .incrby(encoding="i8", offset=100, increment=100) \
  .execute()

redis.bitfield_ro("test_key_2") \
  .get(encoding="u8", offset=0) \
  .get(encoding="u8", offset="#1") \
  .execute()

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.

redis.execute(["XLEN", "test_stream"])

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