redis

Python-redis keys() returns list of bytes objects instead of strings

Python-redis keys() returns list of bytes objects instead of strings Question: I’m using the regular redis package in order to connect my Python code to my Redis server. As part of my code I check if a string object is existed in my Redis server keys. string = ‘abcde’ if string in redis.keys(): do something.. …

Total answers: 4

Celery: When should you choose Redis as a message broker over RabbitMQ?

Celery: When should you choose Redis as a message broker over RabbitMQ? Question: My rough understanding is that Redis is better if you need the in-memory key-value store feature, however I am not sure how that has anything to do with distributing tasks? Does that mean we should use Redis as a message broker IF …

Total answers: 2

Does the redis-py module work with Redis in Cluster mode?

Does the redis-py module work with Redis in Cluster mode? Question: I’m trying to use redis-py with redis in cluster mode, but I can’t get it to work. I see that redis-py-cluster works, but I have a preference for redis-py as I have been using it and it’s a recommended client. Asked By: pettinato || …

Total answers: 3

How to set/get pandas.DataFrame to/from Redis?

How to set/get pandas.DataFrame to/from Redis? Question: After setting a DataFrame to redis, then getting it back, redis returns a string and I can’t figure out a way to convert this str to a DataFrame. How can I do these two appropriately? Asked By: Alex Luya || Source Answers: set: redisConn.set(“key”, df.to_msgpack(compress=’zlib’)) get: pd.read_msgpack(redisConn.get(“key”)) Answered …

Total answers: 6

Django Channels Error – Cannot import BACKEND 'asgi_redis.RedisChannelLayer'

Django Channels Error – Cannot import BACKEND 'asgi_redis.RedisChannelLayer' Question: I have installed Django-Channels but while running the daphne-server I am getting this error given below: File “/usr/local/lib/python2.7/dist-packages/channels/asgi.py”, line 36, in make_backend “Cannot import BACKEND %r specified for %s” % (self.configs[name][‘BACKEND’], name) channels.asgi.InvalidChannelLayerError: Cannot import BACKEND ‘asgi_redis.RedisChannelLayer’ specified for default My settings.py is: CHANNEL_LAYERS = { …

Total answers: 8

How to check if celery result backend is working

How to check if celery result backend is working Question: I am using celery with Redis. Current Redis is used as a broker and as a result backend. BROKER_TRANSPORT = ‘redis’ BROKER_URL = ‘redis://domain:8888/0’ CELERY_RESULT_BACKEND = ‘redis://domain:8888/0’ I want to clear few things: What is the benefit of using the result backend? I mean what …

Total answers: 2

How to store and retrieve a dictionary with redis

How to store and retrieve a dictionary with redis Question: # I have the dictionary my_dict my_dict = { ‘var1’ : 5 ‘var2’ : 9 } r = redis.StrictRedis() How would I store my_dict and retrieve it with redis. For example, the following code does not work. #Code that doesn’t work r.set(‘this_dict’, my_dict) # to …

Total answers: 14

How to insert Billion of data to Redis efficiently?

How to insert Billion of data to Redis efficiently? Question: I have around 2 billion key-value pairs and I want to load them into Redis efficiently. I am currently using Python and used Pipe as documented by the redis-py. How can I speed the following approach up? import redis def load(pdt_dict): “”” Load data into …

Total answers: 5