Redis/AWS Airflow Managed Service - zsets are returned as type string, prohibiting the use of zrange methods (aioredis Python Client)

Viewed 143

I am using Managed Apache Airflow (v 1.10.12) in AWS to create a DAG for a Redis database.

Data is currently being fed into Redis using python with the following code:

redis.zadd(timestamp_key, {message.id: arrow.get(message.time).timestamp()})

timestamp_key would then be a ZSET containing message.id as the value and a timestamp as the score.

To retrieve these values and scores, I first use redis.scan_iter("matchingstring:*") to create an iterator of all timestamp_keys, then use redis.zrangebyscore(timestamp_key, min_value, max_value) to iterate over each element, which is the part that doesn't work.

This gives a ERROR - WRONGTYPE Operation against a key holding the wrong kind of value because redis.type(timestamp_key) returns the value to be a string instead of a ZSET, which prevents the use of any ZRANGE methods.

I have had success with running this code locally (not using Airflow).

0 Answers
Related