March 2020
Intermediate to advanced
608 pages
17h 17m
English
Just like with Memcached, we set caching for the view using the @cache_page decorator. So, each response is cached for 60 seconds for every user. A viral video detail view (such as the one at http://127.0.0.1:8000/en/videos/1/) shows the number of impressions by authenticated and anonymous users. With caching enabled, if you refresh the page a few times, you will notice that the number of impressions changes only once a minute.
Just like Memcached, Redis is a key-value store, and when used for caching, it generates the key for each cached page based on the full URL. When two visitors access the same page simultaneously, the first visitor's request would receive the page generated by the Python code, and the second one would ...