101 questions
1
vote
1
answer
116
views
Execute callback when django.cache.set timeout is exceeded
I use Django cache with django-redis==5.0.0 like this:
cache.set(f'clean_me_up_{id}', timeout=10)
Storing an entry into cache, which will be cleared after timeout, works perfectly for me.
What I´m ...
1
vote
0
answers
215
views
How to optimize a bulk query to redis in django - hiredis
I am porting a rest/graphql api from a Java project to Django in Python. We are using redis in both. We have one endpoint that is rather large (returns several MB). In this endpoint we construct a key ...
9
votes
0
answers
1k
views
Resolving ImportError: Module "redis.connection" does not define a "HiredisParser" attribute/class
My django project has this issue after I updated my redis to version 5.4.0. It seems that the HiredisParser that I was using in my PARSER_CLASS in the redis configuration could not be found in this ...
1
vote
1
answer
875
views
Can't use redis password with special characters in django
I have a redis server with authentication password containing =, and ?. Meanwhile I am using the Location scheme as redis://[:password]@localhost:6397.
Config:
'default': {
'BACKEND': 'django_redis....
0
votes
1
answer
1k
views
Upgrading Redis to 7.0.11 results in TypeError at /login/ __init__() got an unexpected keyword argument 'ssl_cert_reqs'
We use redis with django-rq to manage queues on our project. Heroku has recently forced upgrades to Redis 7.0.11 and that requires TLS. Per their docs we need to set 'ssl_cert_reqs'=None in order to ...
3
votes
0
answers
3k
views
Redis connection scheduled to be closed ASAP for overcoming of output buffer limits
I have some celery tasks that run on VMs to run some web crawling tasks.
Python 3.6, Celery 4.2.1 with broker as Redis (self-managed). The same Redis server is used for caching and locks.
There are ...
1
vote
0
answers
368
views
does django-redis support retry on TimeOut Exception while doing CRUD operation on Redis?
I am using the django-redis package version (4.12.1),
I am getting a TimeOut Exception(Intermittent issue) while reading data from the Redis cache, I would like to Retry for some N number of times to ...
2
votes
1
answer
1k
views
Django Redis cache get TTL (expire time)
Is it possible to get key's expire time in Django using Redis cache?
Something like:
from django.core.cache import cache
cache.get_expire('mykey') # 300 (seconds)
I tried:
cache.ttl('my_key')
...
0
votes
1
answer
262
views
django-redis and redis returning different results
I am using django-redis in my server to make less queries to the db. I recently setup a lambda where I needed to access the same data from the redis cache. But it seems that I am served different data ...
1
vote
1
answer
209
views
Redis GRAPH | unable to set TTL to the node and edge created in redis graph via python
I am using redis graph in my django project to save huge number of data nodes. I am not able to set the expire time of these nodes so the redis data keeps on increasing.
I do not want to set a TTL in ...
2
votes
0
answers
337
views
Does Django open and close connection to cache every time I call cache.delete(key)?
Consider the following code snippet:
from django.core.cache import cache
cache.delete('key_1')
cache.delete('key_2')
If i'm using an Instance of Redis as my default cache, will Django create two ...
1
vote
1
answer
543
views
Using fakeredis in a Django development settings file?
My Django settings.py file contains the following configuration options:
# Caches
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
'LOCATION': '...
3
votes
0
answers
607
views
Django Channels AsyncWebSocketConsumer ConnectionClosedError 1005
I am writing a django channels application and noticed an exception when handling a heartbeat function related to websocket status code which I haven't been able to find any existing issues for. This ...
2
votes
1
answer
1k
views
Cannot connect to redis while using Sentinels in django-redis
Currently I am trying to integrate redis into my django project which is docker based. I was able to integrate redis using the DefaultClient but it doesn't work for SentinelClient
My settings.py looks ...
0
votes
0
answers
388
views
django @cache_page decorator not setting a cache
Here's my cache setting:
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://127.0.0.1:6379',
'OPTIONS': {
'CLIENT_CLASS': '...
0
votes
0
answers
479
views
Error 111 connecting to 127.0.0.1:6379. Connection refused. cPanel (Django)
I'm using django-redis for caching. Everything works fine on local, but I got an error on production development (using cPanel).
Does anyone know how to use django-redis on the production server?
0
votes
1
answer
71
views
Can django-redis use dbsize?
django-redis source: https://github.com/jazzband/django-redis/tree/master/django_redis
my problem is I can not find method to get number of keys in Redis database, it call dbsize. Methods that ...
2
votes
1
answer
812
views
ReadOnlyError in Django application with Redis and DjangoCannels
I have a Django app using DgangoChannels, Djangochannelrestframework. It establishes a websocket connection with ReactJS frontend. As channel layers I use Redis like that
CHANNEL_LAYERS = {
"...
0
votes
1
answer
1k
views
django-redis persisting json data
I have a small django site which controls an anstronomy dome and house automation. On start up the project loads 3 json files: relays, conditions and homeautomation. To avoid constant reading and ...
3
votes
1
answer
7k
views
redis-sentinel connection error in django with "AUTH <password> called without any password configured for the default user. Are you sure ..."
I have a problem with the redis-sentinel connection.
I tried to connect redis-sentinel by using django-redis.
# redis connection factory
DJANGO_REDIS_CONNECTION_FACTORY = 'django_redis.pool....
0
votes
0
answers
2k
views
Django Redis Caching how can i set cache timeout to none (never expiring cache) in class base view
I'm using redis server for caching. Using django-redis package.
Below is my setting file :
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://...
1
vote
0
answers
2k
views
Why does accessing Django cache during unit tests (manage.py test) produces datetime.datetime objects instead of expected values?
I have a Django app, and I'm trying to create unit tests for functions/methods that work with the cache. My tests are run using python manage.py test using the same Docker container that I use for ...
0
votes
1
answer
1k
views
redis in django requirements
hello friends i work in Django project and use Redis for its chache.i run Redis in my local and i use docker for run Redis to (both Redis in local and Docker Rdis are ok and work for me for have redis ...
0
votes
0
answers
3k
views
RedisCache' object has no attribute 'ttl'
hello friends in new project i use Django4 and i set the "django.core.cache.backends.redis.RedisCache" for the cache but i have the error it say
"AttributeError: 'RedisCache' object has ...
0
votes
1
answer
491
views
How to notify users of new blog post via django?
I am building a mobile app using Django Rest Framework, Flutter, and MongoDB. In that app users can view posts posted by other users.
In my Django app, I don't have any notification model (and ...
3
votes
2
answers
2k
views
Django and redis adding :1 to keys
I'm using django-redis to store some data on my website, and I have a problem where Redis is adding :1 at the beginning so my key looks like this: :1:my_key
I'm not sure why is it doing this, I've ...
0
votes
1
answer
5k
views
OperationalError, Error 111 connecting to 127.0.0.1:6379. Connection refused. After deploying in heroku
I am getting the below error after I deployed my website on heroku.
Error 111 connecting to 127.0.0.1:6379. Connection refused.
Request Method: POST
Request URL: https://website.herokuapp.com/...
1
vote
1
answer
2k
views
How to write python unittest cases to mock redis connection (redis.StrictRedis) in Django
How can I mock the following function for connecting to Redis?
import redis
class RedisCache:
redis_instance = None
@classmethod
def set_connect(cls):
redis_instance = redis....
3
votes
2
answers
1k
views
What are the differences among django_redis, channels_redis, asgi_redis and redis server?
I am new to Django and right now i'm learning Django async with Channels. I have noticed some programmers use channels_redis for their projects, some use django_redis, some use asgi_redis and i found ...
-1
votes
1
answer
757
views
How to see keys set by django-ratelimit in redis server?
I am using the following
django==3.1.3
django-ratelimit==3.0.1
django-redis==4.12.1
djangorestframework==3.12.2
I am trying to set up a rate-limit to limit the number of times a POST request is ...
1
vote
2
answers
3k
views
Caching serializer responses in Django Rest Framework
I am using serializer to get the related data for a particular resource like this:
SessionSerializer.py
def to_representation(self, instance):
response = super().to_representation(instance)
...
1
vote
0
answers
248
views
New records not coming in the list call of Django DRF API using Redis cache
I have a Django REST API, and I am using Redis as the caching backend.
Code
@method_decorator(cache_page(60*60))
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **...
0
votes
0
answers
385
views
How to effectively manage cache (Redis) with Django Rest Framework?
We have been working with Django and Django RestFramework for quite a time now and facing a lot of challenging to manage cache in Redis, our models look like
(1) School (Details of School)
(2) Teacher ...
1
vote
1
answer
1k
views
How to check if redis connection is available when server starts running in django rest framework and return the error response if not connected
I'm doing multiple API calls but in each API call I'm checking if redis connection is available.
showing only one of the API calls below.
def check_redis_conn():
redis_exists = RedisCache....
2
votes
1
answer
3k
views
Django Use multiple redis for caching
I have a Django project and i am using django-redis where I want to implement different types of caching,
Caching search query
Caching static pages
Cache user Data (eg: online status)
I can add ...
7
votes
1
answer
1k
views
Django Channels Redis: Exception inside application: Lock is not acquired
Fully loaded multi-tenant Django application with 1000's of WebSockets using Daphne/Channels, running fine for a few months and suddenly tenants all calling it the support line the application running ...
1
vote
1
answer
2k
views
Django-q: WARNING reincarnated worker Process-1:1 after timeout
I've installed and configured Django-Q 1.3.5 (on Django 3.2 with Redis 3.5.3 and Python 3.8.5).
This is my Cluster configuration:
# redis defaults
Q_CLUSTER = {
'name': 'my_broker',
'workers': ...
1
vote
1
answer
1k
views
Django CACHEOPS different timeout for different querysets
I'm using Django CACHEOPS. cacheops' README
In settings.py how can I config different timeouts for different querysets?
(cache the get queryset for 10 seconds and cache queryset fetches for 60 ...
0
votes
1
answer
434
views
Django redis caching per url
So I am trying to implement moreover learn how to cache Django views per URL. I am able to do so and here is what is happening...
I visit a URL for 1st time and Django sets the caches.
I get my ...
1
vote
1
answer
7k
views
Is there a way to set an expiration time for a Django cache lock?
I have a Django 3.1.3 server that uses Redis for its cache via django-redis 4.12.1. I know that cache locks can generally be set via the following:
with cache.lock('my_cache_lock_key'):
# Execute ...
0
votes
2
answers
2k
views
Can I run redis on a windows server?
I have designed an app in django using django channels with redis servers for websocket communication, but I have to host it on a windows server. I can run the redis server locally on my windows ...
3
votes
1
answer
1k
views
Is it okay to use the same Redis store for both cache and django-channels channel layer in Django?
I have a Django 3.1 app that uses Redis for its cache backing store (django-redis). I wish to use django-channels, which has the ability to use Redis for channel layers.
Is it safe or unsafe to use ...
1
vote
0
answers
341
views
why is django app creating huge keys in redis
I am running django app (wagtail) in kubernetes cluster along with redis. These two pieces are connected by django-redis. This is how my backend configuration look
{
"BACKEND":"...
1
vote
1
answer
1k
views
[Django rest_framework]Problems in using redis as Django DRF cache
I'm trying to open the redis cache for the rest framework.
My configuration seems to be correct.
When I run, it reports an error. As shown below:
Watching for file changes with StatReloader
Performing ...
1
vote
1
answer
494
views
(Django) RQ scheduler - Jobs disappearing from queue
Since my project has so many moving parts.. probably best to explain the symptom
I have 1 scheduler running on 1 queue. I add scheduled jobs ( to be executed within seconds of the scheduling).
I keep ...
9
votes
3
answers
16k
views
Django channel Error "took too long to shut down and was killed."
I am getting this error on my console log, and on form submit it keeps loading does not post data to the server.
/home/Python/Working/Benutzerverwaltung/env/lib/python3.6/site-packages/channels/...
0
votes
0
answers
355
views
django-redis-cache creates random keys with integer values
I am using the following in my Django project:
django-redis-cache==2.1.1
redis==3.5.5
Django==2.2.13
Python 3.7.5
In my settings.py I specified the following cache:
CACHES = {
"default":...
0
votes
2
answers
366
views
how to deactivate compressor in django-redis?
I am using django-redis in django and want to turn off compressor. there are several options to set various types of compressors like zlib, lzma, etc. but not no compressor.
1
vote
1
answer
758
views
Is it a good idea to use cache and how to use it for 4000-10000 data rows in Django for a single page?
Django 2.2
I need to fetch 4000-10000 data rows from a particular datatable (let's call this commonsites) amongst others to display a webpage.
I can narrow down to just 3 fields of these 4000-10000 ...
2
votes
1
answer
6k
views
Error accessing AWS elasticache redis in cluster mode) + TLS Enabled from django service
I'm trying to connect AWS elasticache(redis in cluster mode) with TLS enabled, the library versions and django cache settings as below
====Dependencies======
redis==3.0.0
redis-py-cluster==2.0.0
...