memcached

How to cache Django Rest Framework API calls?

How to cache Django Rest Framework API calls? Question: I’m using Memcached as backend to my django app. This code works fine in normal django query: def get_myobj(): cache_key = ‘mykey’ result = cache.get(cache_key, None) if not result: result = Product.objects.all().filter(draft=False) cache.set(cache_key, result) return result But it doesn’t work when used with django-rest-framework api calls: …

Total answers: 2

Installing pylibmc on Ubuntu

Installing pylibmc on Ubuntu Question: When running pip install pylibmc on Ubuntu, I get the following error: _pylibmcmodule.h:42:36: fatal error: libmemcached/memcached.h: No such file or directory Asked By: Zags || Source Answers: sudo apt-get install libmemcached-dev zlib1g-dev Answered By: Zags Zags answer didn’t do the trick for me on Ubuntu 13.10. libmemcached-dev had already been …

Total answers: 3

Error when install pylibmc using pip

Error when install pylibmc using pip Question: Hello when I attempt to install pylibmc on OSX Lion using pip I get the following error: ./_pylibmcmodule.h:42:10: fatal error: ‘libmemcached/memcached.h’ file not found #include <libmemcached/memcached.h> ^ 1 error generated. error: command ‘clang’ failed with exit status 1 Any clues at how to solve this issue? Asked By: …

Total answers: 10

Django Caching for Authenticated Users Only

Django Caching for Authenticated Users Only Question: Question In Django, how can create a single cached version of a page (same for all users) that’s only visible to authenticated users? Setup The pages I wish to cache are only available to authenticated users (they use @login_required on the view). These pages are the same for …

Total answers: 5

Get list of Cache Keys in Django

Get list of Cache Keys in Django Question: I’m trying to understand how Django is setting keys for my views. I’m wondering if there’s a way to just get all the saved keys from Memcached. something like a cache.all() or something. I’ve been trying to find the key with cache.has_key(‘test’) but still cant figure out …

Total answers: 11

Clearing specific cache in Django

Clearing specific cache in Django Question: I am using view caching for a django project. It says the cache uses the URL as the key, so I’m wondering how to clear the cache of one of the keys if a user updates/deletes the object. An example: A user posts a blog post to domain.com/post/1234/ .. …

Total answers: 4

How do I check the content of a Django cache with Python memcached?

How do I check the content of a Django cache with Python memcached? Question: Tools version: Python 2.6.5 Django 1.3.1 memcached 1.4.10 python-memcached 1.48 Memcached is currently running: $ ps -ef | grep memcache nobody 2993 1 0 16:46 ? 00:00:00 /usr/bin/memcached -m 64 -p 11211 -u nobody -l 127.0.0.1 I’m using memcached and python …

Total answers: 3

best place to clear cache when restarting django server

best place to clear cache when restarting django server Question: I want memcached to be flushed on every restart/reload of django server. I use cherrypy for production and builtin server for development. I would add this to settings.py, right after CACHES: from django.core.cache import cache cache.clear() but it makes a recursive import: Error: Can’t find …

Total answers: 5

Maximum size of object that can be saved in memcached with memcache.py

Maximum size of object that can be saved in memcached Question: I need to return a rather big file (11MB) to the user. For certain reasons, I can’t just provide a direct url to the file (http://www.sample.com/mybigfile.exe); instead it must be accessed through code. Instead of having to read it from disk over and over, …

Total answers: 8