Redis Documentation

Usage

The Symbols Service webapp uses Redis for miscellaneous caching and as a broker for message queue workers (TO BE UPDATED).

Usage In Django

Within the Django code, these two are accessible in this way:

from django.core.cache import caches

regular_cache = caches['default']

The first (“default”) cache is also available in this form:

from django.core.cache import cache

regular_cache = cache

Because it uses the django-redis and the Django Cache framework API you can use it for all other sorts of caching such as caching sessions or cache control for HTTP responses. Another feature of this is that you can bypass the default expiration by explicitly setting a None timeout which means it’s persistent. For example:

from django.core.cache import cache

cache.set('key', 'value', timeout=None)

CLIs

To go into CLI of the Redis database use this shortcuts:

$ make redis-cache-cli

From there you can see exactly what’s stored. For example, to see the list of all symbols stored in the LRU cache:

$ make redis-cache-cli

redis-cache:6379> keys *
1) ":1:count_missing:20211225:20220124"
2) ":1:count_missing:20220124:20220125"
3) ":1:count_missing:20220123:20220124"
4) ":1:count_missing:20211226:20220125