Ticket #15888: 15888-docs.patch

File 15888-docs.patch, 4.4 KB (added by Aymeric Augustin, 14 years ago)
  • docs/topics/cache.txt

     
    159159Database caching
    160160----------------
    161161
    162 To use a database table as your cache backend, first create a cache table in
    163 your database by running this command::
     162Django can store its cached data in your database. This works best if you've
     163got a fast, well-indexed database server.
    164164
    165     python manage.py createcachetable [cache_table_name]
     165To use a database table as your cache backend:
    166166
    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.
    172172
    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``::
     173In this example, the cache table's name is ``my_cache_table``::
    178174
    179175    CACHES = {
    180176        'default': {
     
    183179        }
    184180    }
    185181
     182Creating the cache table
     183~~~~~~~~~~~~~~~~~~~~~~~~
    186184
    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.
     185Before using the database cache, you must create the cache table with this
     186command::
    189187
    190 Database caching works best if you've got a fast, well-indexed database server.
     188    python manage.py createcachetable
    191189
    192 Database caching and multiple databases
    193 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     190This creates a table in your database that is in the proper format that
     191Django's database-cache system expects. The name of the table is taken from
     192:setting:`LOCATION <CACHES-LOCATION>`.
    194193
     194If you are using multiple database caches, :djadmin:`createcachetable` creates
     195one table for each cache.
     196
     197If you are using multiple databases, :djadmin:`createcachetable` observes the
     198``allow_syncdb()`` method of your database routers (see below).
     199
     200Like :djadmin:`syncdb`, :djadmin:`createcachetable` won't touch an existing
     201table. It will only create missing tables.
     202
     203.. versionchanged:: 1.4
     204
     205Before Django 1.4, :djadmin:`createcachetable` created one table at a time.
     206You had to pass the name of the table you wanted to create in argument,
     207and if you were using multiple databases, you had to use the
     208:djadminopt:`--database` option. For backwards compatibility,
     209this is still possible.
     210
     211Multiple databases
     212~~~~~~~~~~~~~~~~~~
     213
    195214If you use database caching with multiple databases, you'll also need
    196215to set up routing instructions for your database cache table. For the
    197216purposes of routing, the database cache table appears as a model named
     
    247266        }
    248267    }
    249268
    250 
    251269If you're on Windows, put the drive letter at the beginning of the path,
    252270like this::
    253271
  • docs/ref/django-admin.txt

     
    111111
    112112.. django-admin:: createcachetable
    113113
    114 Creates a cache table named ``tablename`` for use with the database cache
    115 backend. See :doc:`/topics/cache` for more information.
     114Creates the cache tables for use with the database cache backend. See
     115:doc:`/topics/cache` for more information.
    116116
    117117.. versionadded:: 1.2
    118118
    119119The :djadminopt:`--database` option can be used to specify the database
    120120onto which the cachetable will be installed.
    121121
     122.. versionchanged:: 1.4
     123
     124It is no longer necessary to provide the cache table name in argument or the
     125:djadminopt:`--database` option. Django takes this information from your
     126settings file. If you have configured multiple caches or multiple databases,
     127all the cache tables are created.
     128
    122129dbshell
    123130-------
    124131
Back to Top