How is the caches parameter configured in the Django cache optimization?

Source: Internet
Author: User
Tags memcached

CACHES configuration Parameters Overview-format

CACHES Dictionary configuration format is as follows

{
' Default ': {
' Backend ':
' Django.core.cache.backends.locmem.LocMemCache ',
}
}

The default cache must be configured when you configure the CACHES dictionary


CACHES configuration Parameters Overview-Backend

Supported backend:

1) ' Django.core.cache.backends.db.DatabaseCache '
2) ' Django.core.cache.backends.dummy.DummyCache '
3) ' Django.core.cache.backends.filebased.FileBasedCache '
4) ' Django.core.cache.backends.locmem.LocMemCache '
5) ' Django.core.cache.backends.memcached.MemcachedCache '
6) ' Django.core.cache.backends.memcached.PyLibMCCache '
Configurable cache back-end list

CACHES Configuration Parameters Overview-Additional parameters

Each cache backend can set additional parameters to control the caching behavior. The following parameters can be configured:

1) TIMEOUT

Cache default expiration time (seconds), 300s (5mins) not set

2) OPTIONS

Optional configuration, different back end, optional configuration options

3) Key_prefix

The default is automatically added to the front of all cache keys

4) VERSION

Default cache keys for version

5) Key_function

Generate final cache function path for keys

Like Locmem, filesystem and database caches implement the cull policy with the following parameters:
Culling policy parameters (options):
Max_entries
Maximum number of allowed in the cache before old data is deleted, default: 300
Cull_frequency
When the number of caches reaches max_entries, a partial cache is deleted, the deletion rate is 1/cull_requency, and if cull_frequency = 2, half of the data is deleted when the max_entries is reached. Default value: 3


CACHES Configuration Parameters Overview-Example

CACHES = {
' Default ': {
' Backend ': ' Django.core.cache.backends.filebased.FileBasedCache ',
' Location ': '/var/tmp/django_cache ',
' TIMEOUT ': 60,
' OPTIONS ': {
' Max_entries ': 1000
}
}
}

Note: Invalid parameters are ignored and do not affect the entire project

How is the caches parameter configured in the Django cache optimization?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.