Questions tagged [redis-py]

A Python interface to the Redis key-value store.

A Python interface to the Redis key-value store.

redis-py is developed and maintained by Andy McCurdy (sedrik@gmail.com).

It can be installed in your python environment using pip install redis or if you download the source from above link you can run python setup.py install

221 questions
0
votes
1 answer

Difference of get() and find() in redis-om redisjson

I was wondering why the following 2 examples do NOT return the same. ts = Signal.find(Signal.pk == pk).all() ts = Signal.get(pk) The first line returns an empty array. (Only if I restart the FastAPI, after inserting, it returns the values) The…
feder
  • 1,849
  • 2
  • 25
  • 43
0
votes
1 answer

How to save redis om (HashModel) to a redis stream?

I can easily convert a redis-om Model to a string and then append the string to the stream. r.xadd(name="myStream", fields= {'mydict': json.dumps(sensorSignal.json())}) What is the best/leanest practice to store that object in the stream in order…
feder
  • 1,849
  • 2
  • 25
  • 43
0
votes
2 answers

The INCRBY instruction executed by a Redis pipeline return a reference to the pipeline instead the value of the key modified

I have some problem to use Redis pipeline. I need to execute 2 commands (incr() and set()) by a Redis transaction. Environment info: redis-py version 3.5.3; the version of the Redis server is v=5.0.5. So I have tried to use the following code (the…
frankfalse
  • 1,553
  • 1
  • 4
  • 17
0
votes
0 answers

How to save most recent timestamp in Redis?

I need a way to cache the timestamp of the most recently modified record for a certain table in a non-redis database. So when the caller tries to write that timestamp to redis, it should skip writing if there's already a newer value, which could…
jacob
  • 2,762
  • 1
  • 20
  • 49
0
votes
1 answer

aioredis.exceptions.ConnectionError: Connection closed by server

I get this error randomly with redis on heroku. aioredis.exceptions.ConnectionError: Connection closed by server. this is the full trace: 2023-03-25T23:34:34.116795+00:00 app[web.1]: There was an exception checking if the field exists in the…
3awny
  • 319
  • 1
  • 2
  • 10
0
votes
1 answer

How to replicate tail -f behavior with redis-py XREAD

I am using Redis streams and basically have a stream that will append an END sentinel message when it's done. Until then, I basically want to mimic tail -f which is when I begin a read I want to see all previous logs until the current time and then…
0
votes
1 answer

How to append element to key type list, element is type dictionary

I have below code, I can create a key type list, and its element is type dictionary? Sorry, My english is not good. field_list = [ {'name': 'abc', 'age': 22}, {'name': 'dec', 'age': 34}, {'name': 'xyz', 'age': 65}, {'name': 'wqe',…
Tú Phan
  • 13
  • 4
0
votes
0 answers

"lrange()" function isn't working on redis-py

I have a Redis db locally on my machine, and I store lists in it. The storing process works fine, but I can't access the lists via pytho code. I tried doing: redis_data = redis_client.lrange('TLV-NYC', 0, -1) # or redis_data =…
0
votes
0 answers

redis.exceptions.ConnectionError: Error UNKNOWN while writing to socket. Connection lost

For my python (python 3.10) based project, we were using aioredis (aioredis 2.0.1) to connect to redis cache and all of a sudden all the requests accessing redis cache started failing. After analysis, we found that Aioredis is now in redis-py. Post…
Kashyap
  • 385
  • 3
  • 13
0
votes
0 answers

How to modify RedisClusterRequestTTL to an RedisCluster instance in redis-py-cluster

class RedisCluster(Redis): """ If a command is implemented over the one in Redis then it requires some changes compared to the regular implementation of the method. """ RedisClusterRequestTTL = 16 RedisClusterRequestTTL is a constant which control…
0
votes
0 answers

How to initialise connection pool with "n" connections in Redis python library using redis.ConnectionPool

In the Redis Python library, the redis.ConnectionPool class is used to create and manage a pool of connections to a Redis server. A connection pool is an object that maintains a set of idle connections that can be used to send commands to the Redis…
asaxena
  • 1
  • 2
0
votes
1 answer

Flask-Caching not connecting to redis cluster in disabled cluster mode (aws hosted)

I am using the flask-caching library to use caching in my flask app. I am following the docs here: https://flask-caching.readthedocs.io/en/latest/#redisclustercache When trying the connection on a cluster-enabled-mode cluster locally it works,…
0
votes
1 answer

Make composite key to a primary key in noSQL key-value database redis-py

I'm very new to noSQL and the first task is with redis. I have to create a key-value database witih a composite key but as I searched there is no such thing in Redis (or it is called differently). My sql DB would have 4 attributes: Name, Surname,…
Naumedis
  • 1
  • 1
0
votes
0 answers

How to receive the return value when the type hint is Union[Awaitable[int], int]?

My python code is using redis-py to query redis. I noticed the return value type hint of redis-py functions are always like: Union[Awaitable[int], int]: (e.g. redis.commands.core.py:L4824) def hlen(self, name: str) -> Union[Awaitable[int],…
Liii
  • 1
0
votes
1 answer

Stroing a list in redis-py

I'm trying to store a list generated from a dict in my redis db, using the following commands: x = {'TLV-IST#2022-12-27~2023-01-04': '252', 'TLV-IST#2022-12-27~2023-01-17': '300'} for key, value in x.items(): client.lpush(key[:7], key[8:] + '#'…