Django load resources on startup
<p>How can I load resources from mysql database when Django starts up and put it in memory (Redis) to use by all the applications. </p>

<p>I have seen this [<a href="https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.ready]" rel="nofollow">https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.ready]</a></p>

<pre><code>class MyAppConfig(AppConfig):
        def ready(self):
</code></pre>

<p>But they mention not use db connections inside ready function. How can do it when my Website starts.?</p>

<p>And Can I also set cache value inside ready ?</p>

<pre><code>from django.core.cache import cache
cache.set()
</code></pre>

<p>Since you are only loading into redis rather than creating instances of models that are held in memory and shared by all apps in your website, perhaps the best way is to use a <a class='doc-link' href="http://stackoverflow.com/documentation/django/1661/management-commands/5367/creating-and-running-a-management-command#t=201609160431023464416">custom management command</a> or create a <a class='doc-link' href="http://stackoverflow.com/documentation/django/5848/django-from-the-command-line/20596/django-from-the-command-line#t=201609160434189987315">Django CLI</a></p>

<p>Since you are using redis, do you really need to store things in memcache as well? But if you need to that too is something that can be done from a CLI</p>

python django apache redis