To use a database table as your cache back-end, create a cache table in your database and point Django’s cache system at that table.
First, create a cache table by running this command:
python manage.py createcachetable [cache_table_name]
where [cache_table_name] is the name of the database table to create. This name can be whatever you want, as long as it’s a valid table name that’s not already being used in your database. This command creates a single table in your database that is in the proper format Django’s database-cache system expects.
Once you’ve created that database table, set your CACHE_BACKEND setting to "db://tablename", wheretablename is the name of the database table. In this example, the cache table’s name is my_cache_table:
CACHE_BACKEND = 'db://my_cache_table'
The database caching back-end uses the same database as specified in your settings file. You can’t use a different database back-end for your cache table.
No comments:
Post a Comment