django cache is configured with a variety of ways, mainly includes the following:
1. The development and debugging mode
2. Memory Mode
3. Use the file
4. Use direct database
5. Use or memcache redis
This is mainly the record about those not commonly used, but in micro-projects or beta configuration can be used (mainly record what BACKEND, engine )
Memory Mode
= CACHES { ' default ' : { ' BACKEND ' : ' django.core.cache.backends.locmem.LocMemCache ' , ' LOCATION ' : ' lowmanisbusy ' , # must be set to a value, and only when the presence } }
Development and debugging
Description: This is the start debugging, without any actual internal operation CACHES = { ' default ' : { ' BACKEND ' : ' django.core.cache.backends.dummy.DummyCache '
} }
Use File
Description: This cache contents to a file Save
Note: absolute path, the path must be guaranteed to have access django CACHES = { ' default ' : { ' BACKEND ' : ' django.core.cache.backends.filebased.FileBasedCache ' , ' LOCATION ' : ' / var / tmp / django_cache ' , # cache file stored in the path } }
Use Database
Description: This cache to save the contents of the database CACHES = { ' default ' : { ' BACKEND ' : ' django.core.cache.backends.db.DatabaseCache ' , ' LOCATION ' : ' my_cache_table ' , # setting data stored in the cache table name } } # need to create a data sheet: Python manage.py createcachetable