django-cache

Django doesn't use memcached framework

狂风中的少年 提交于 2021-02-08 11:23:21
问题 I'm trying to find out how Django caching framework works. I set memcached in settings.py but the time of loading page didn't get smaller and Django-debug-toolbar shows 0 cache calls. This is what I've set in settings.py: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } CACHE_BACKEND = 'memcached://127.0.0.1:11211/' CACHE_MIDDLEWARE_ALIAS = "default" CACHE_MIDDLEWARE_SECONDS = 60 MIDDLEWARE = [ 'django.middleware

memcache on django is not working

偶尔善良 提交于 2021-01-27 06:07:53
问题 I have a race condition in Celery . Inspired by this - http://ask.github.io/celery/cookbook/tasks.html#ensuring-a-task-is-only-executed-one-at-a-time I decided to use memcache to add locks to my tasks. These are the changes I made: python-memcached # settings for memcache CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } After this I login to my shell and do the following >>> import os >>> import django >>> from django

memcache on django is not working

ⅰ亾dé卋堺 提交于 2021-01-27 06:01:54
问题 I have a race condition in Celery . Inspired by this - http://ask.github.io/celery/cookbook/tasks.html#ensuring-a-task-is-only-executed-one-at-a-time I decided to use memcache to add locks to my tasks. These are the changes I made: python-memcached # settings for memcache CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } After this I login to my shell and do the following >>> import os >>> import django >>> from django

How use Django Cache in view without cache all page

你。 提交于 2020-06-26 14:43:47
问题 I trying to use Django Cache to make better my views. Works great, 400ms to 8ms is perfect. But when user access page for the first time, Django cache page with user info in header and when I try log out, page continue with user info. I try use cache in template too, but isn't good, my problem come from view, so continue 400ms. My settings.py CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake', } } My view.py @cache_page(60 * 15)

Caching Zip Object With Django Memcached

二次信任 提交于 2020-01-16 17:26:41
问题 I am currently using Django and memcached to keep track of a Zip object like so: activeList_data = cache.get(active_list_key) if not activeList_data: activeTickers, activeName = get_most_active() activeList = zip(activeTickers, activeName) cache.set(1, activeList, cache_time) However, whenever I try to print the cache it just returns a blank list. Any ideas on where I am going wrong? Thanks EDIT : For reference here is my full code activeList_data = cache.get(active_list_key) # returns None

Django cache framework. What is the difference between TIMEOUT and CACHE_MIDDLEWARE_SECONDS?

天大地大妈咪最大 提交于 2020-01-14 07:36:31
问题 I have been setting up caching in Django using a database cache. There are two settings TIMEOUT and CACHE_MIDDLEWARE_SECONDS that control how long a page is cached for. What is the difference between these two settings? 回答1: Indeed the respective documentation does not adequately explain the differences. The first option, CACHES : TIMEOUT is introduced in Django cache framework, Cache arguments. It is the default expiration time that is used in functions such as cache.set() , if none else is

Caching for anonymous users in django

回眸只為那壹抹淺笑 提交于 2020-01-03 08:27:22
问题 How would I go about caching pages for anonymous users but rendering them for authorized users in Django 1.6? There used to be a CACHE_MIDDLEWARE_ANONYMOUS_ONLY flag that sounded perfect, but that has gotten removed. I'm asking because every page has a menu bar that displays the logged in user's name and a link to his/her profile. What's the correct way of doing this? Must be a common problem, but I haven't found the right way from looking through the Django documentation. 回答1: this does not

What steps are needed to implement memcached in a Django application?

回眸只為那壹抹淺笑 提交于 2019-12-24 12:59:08
问题 I have my existing Django web application that uses a MySQLDB without memcaching. I would like to implement memcaching to improve the responsiveness of this site. I see the instructions here. However, these instructions leave me with some unanswered question(s). Is this all I need to do to get memcache working after I setup the memcached server? Or do I need to alter any of my code outside of settings.py? Does Django nicely handle all the memcaching operations behind the scenes for me

Django global data for threads

走远了吗. 提交于 2019-12-23 12:48:27
问题 I have a shared global data object in my single-process multi-threaded django server - an object which is frequently used, but calculated infrequently. The calculation is time-consuming, so I want to share the results. I thought it would work to use django's LocalMemCache for this simple data. Oddly, it seems to work for multiple ajax calls on a single page load, but for some reason, when I reload the page in my browser, the cache is empty again. What am I doing wrong? Is there a better way?