开发者

does django have a memory based cache or do you have to use memcache?

开发者 https://www.devze.com 2023-01-04 07:37 出处:网络
can I store objects in the servers memory to cache data using django, 开发者_开发知识库or do I have to use memcache for that?There are a variety of options, including using the server\'s memory:

can I store objects in the servers memory to cache data using django, 开发者_开发知识库or do I have to use memcache for that?


There are a variety of options, including using the server's memory:

  • Memcached
  • Database caching
  • Filesystem caching
  • Local-memory caching
  • Dummy caching (for development)
  • Using a custom cache backend

To use the server's memory, in settings.py, you should set the cache backend as follows:

CACHE_BACKEND = 'locmem://'

See the following page in the Django documentation for further information on the various cache backends and for details on how to enable caching: http://docs.djangoproject.com/en/dev/topics/cache/


Django does allow many types of caching such as file system and local memory caching. In local memory caching, each process has its own private cache instance, which means no cross-process caching is possible because they exist in different virtual memories. Hence, local memory caching is not efficient for production environments.

Memcache is preferable because it solves that problem and is really fast as it runs on RAM. Django admits that Memcache is fastest on its website.

Memcache is also free and easy to install (sudo apt-get install memcached). You also need something to bind python to Memcache such as python-memcached.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号