Ticket #15888: 15888-docs.patch
File 15888-docs.patch, 4.4 KB (added by , 14 years ago) |
---|
-
docs/topics/cache.txt
159 159 Database caching 160 160 ---------------- 161 161 162 To use a database table as your cache backend, first create a cache table in 163 your database by running this command:: 162 Django can store its cached data in your database. This works best if you've 163 got a fast, well-indexed database server. 164 164 165 python manage.py createcachetable [cache_table_name] 165 To use a database table as your cache backend: 166 166 167 ...where ``[cache_table_name]`` is the name of the database table to create. 168 (This name can be whatever you want, as long as it's a valid table name that's 169 not already being used in your database.) This command creates a single table 170 in your database that is in the proper format that Django's database-cache 171 system expects.167 * Set :setting:`BACKEND <CACHES-BACKEND>` to 168 ``django.core.cache.backends.db.DatabaseCache`` 169 * Set :setting:`LOCATION <CACHES-LOCATION>` to ``tablename``, the name of 170 the database table. This name can be whatever you want, as long as it's 171 a valid table name that's not already being used in your database. 172 172 173 Once you've created that database table, set your 174 :setting:`BACKEND <CACHES-BACKEND>` setting to 175 ``"django.core.cache.backends.db.DatabaseCache"``, and 176 :setting:`LOCATION <CACHES-LOCATION>` to ``tablename`` -- the name of the 177 database table. In this example, the cache table's name is ``my_cache_table``:: 173 In this example, the cache table's name is ``my_cache_table``:: 178 174 179 175 CACHES = { 180 176 'default': { … … 183 179 } 184 180 } 185 181 182 Creating the cache table 183 ~~~~~~~~~~~~~~~~~~~~~~~~ 186 184 187 The database caching backend uses the same database as specified in your 188 settings file. You can't use a different database backend for your cache table. 185 Before using the database cache, you must create the cache table with this 186 command:: 189 187 190 Database caching works best if you've got a fast, well-indexed database server. 188 python manage.py createcachetable 191 189 192 Database caching and multiple databases 193 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 190 This creates a table in your database that is in the proper format that 191 Django's database-cache system expects. The name of the table is taken from 192 :setting:`LOCATION <CACHES-LOCATION>`. 194 193 194 If you are using multiple database caches, :djadmin:`createcachetable` creates 195 one table for each cache. 196 197 If you are using multiple databases, :djadmin:`createcachetable` observes the 198 ``allow_syncdb()`` method of your database routers (see below). 199 200 Like :djadmin:`syncdb`, :djadmin:`createcachetable` won't touch an existing 201 table. It will only create missing tables. 202 203 .. versionchanged:: 1.4 204 205 Before Django 1.4, :djadmin:`createcachetable` created one table at a time. 206 You had to pass the name of the table you wanted to create in argument, 207 and if you were using multiple databases, you had to use the 208 :djadminopt:`--database` option. For backwards compatibility, 209 this is still possible. 210 211 Multiple databases 212 ~~~~~~~~~~~~~~~~~~ 213 195 214 If you use database caching with multiple databases, you'll also need 196 215 to set up routing instructions for your database cache table. For the 197 216 purposes of routing, the database cache table appears as a model named … … 247 266 } 248 267 } 249 268 250 251 269 If you're on Windows, put the drive letter at the beginning of the path, 252 270 like this:: 253 271 -
docs/ref/django-admin.txt
111 111 112 112 .. django-admin:: createcachetable 113 113 114 Creates a cache table named ``tablename`` for use with the database cache115 backend. See:doc:`/topics/cache` for more information.114 Creates the cache tables for use with the database cache backend. See 115 :doc:`/topics/cache` for more information. 116 116 117 117 .. versionadded:: 1.2 118 118 119 119 The :djadminopt:`--database` option can be used to specify the database 120 120 onto which the cachetable will be installed. 121 121 122 .. versionchanged:: 1.4 123 124 It is no longer necessary to provide the cache table name in argument or the 125 :djadminopt:`--database` option. Django takes this information from your 126 settings file. If you have configured multiple caches or multiple databases, 127 all the cache tables are created. 128 122 129 dbshell 123 130 ------- 124 131