File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 3838 'PASSWORD' : conn_str_params ['password' ],
3939 }
4040}
41+
42+ CACHES = {
43+ "default" : {
44+ "BACKEND" : "django_redis.cache.RedisCache" ,
45+ "LOCATION" : os .environ .get ('CACHELOCATION' ),
46+ "OPTIONS" : {
47+ "CLIENT_CLASS" : "django_redis.client.DefaultClient" ,
48+ "COMPRESSOR" : "django_redis.compressors.zlib.ZlibCompressor" ,
49+ 'PASSWORD' : os .environ .get ('CACHEKEY' )
50+ },
51+ }
52+ }
Original file line number Diff line number Diff line change 119119 },
120120]
121121
122+ CACHES = {
123+ "default" : {
124+ "BACKEND" : "django_redis.cache.RedisCache" ,
125+ "LOCATION" : os .environ .get ('CACHELOCATION' ),
126+ "OPTIONS" : {
127+ "CLIENT_CLASS" : "django_redis.client.DefaultClient" ,
128+ 'PASSWORD' : os .environ .get ('CACHEKEY' )
129+ },
130+ }
131+ }
122132
123133# Internationalization
124134# https://docs.djangoproject.com/en/4.0/topics/i18n/
Original file line number Diff line number Diff line change 44from django .urls import reverse
55from django .utils import timezone
66from django .views .decorators .csrf import csrf_exempt
7+ from django .views .decorators .cache import cache_page
78
89from restaurant_review .models import Restaurant , Review
910
1011# Create your views here.
1112
13+ @cache_page (60 )
1214def index (request ):
1315 print ('Request for index page received' )
1416 restaurants = Restaurant .objects .annotate (avg_rating = Avg ('review__rating' )).annotate (review_count = Count ('review' ))
You can’t perform that action at this time.
0 commit comments