A simple Django management command which clears your cache.
Project description
# django-clear-cache
![I don't always clear my cache...](https://github.com/rdegges/django-clear-cache/raw/master/clear_cache.jpg)
I often find myself in situations where I need to fully clear my website's
cache (memcached or whatever). Often times this is required because:
- I'm deploying new code and it will fail to run properly with my currently
cached objects.
- I need to purge invalid (or old) information.
- A *million* other reasons.
The standard way to clear your cache is to open up a management shell, eg:
``` bash
$ python manage.py shell
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.cache import cache
>>> cache.clear()
```
But obviously, this is annoying as I have to manually log into my production
shell.
``django-clear-cache`` makes this process as easy as running a single
management command.
## Install
To install ``django-clear-cache``, simply run ``pip install django-clear-cache``
and you'll get the latest version installed automatically.
Next, modify your Django ``settings.py`` file, and add ``clear_cache`` to your
``INSTALLED_APPS`` setting:
``` python
INSTALLED_APPS = (
# ...
'clear_cache',
)
```
## Usage
To clear your cache, simply run the ``clear_cache`` management command:
``` bash
$ python manage.py clear_cache
Your cache has been cleared!
```
**NOTE**: This will only (obviously) work if you've got a cache configured (eg:
memcached, local memory, etc.). If you have no idea what I'm talking about,
read through the [official Django caching docs](https://docs.djangoproject.com/en/dev/topics/cache/?from=olddocs).
## Tests
[![Build Status](https://secure.travis-ci.org/rdegges/django-clear-cache.png?branch=master)](http://travis-ci.org/rdegges/django-clear-cache)
Want to run the tests? No problem:
``` bash
$ git clone git://github.com/rdegges/django-clear-cache.git
$ cd django-clear-cache
$ python setup.py develop
...
$ python manage.py test clear_cache
Creating test database for alias 'default'...
.Your cache has been cleared!
..
----------------------------------------------------------------------
Ran 3 tests in 1.007s
OK
Destroying test database for alias 'default'...
```
![I don't always clear my cache...](https://github.com/rdegges/django-clear-cache/raw/master/clear_cache.jpg)
I often find myself in situations where I need to fully clear my website's
cache (memcached or whatever). Often times this is required because:
- I'm deploying new code and it will fail to run properly with my currently
cached objects.
- I need to purge invalid (or old) information.
- A *million* other reasons.
The standard way to clear your cache is to open up a management shell, eg:
``` bash
$ python manage.py shell
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.cache import cache
>>> cache.clear()
```
But obviously, this is annoying as I have to manually log into my production
shell.
``django-clear-cache`` makes this process as easy as running a single
management command.
## Install
To install ``django-clear-cache``, simply run ``pip install django-clear-cache``
and you'll get the latest version installed automatically.
Next, modify your Django ``settings.py`` file, and add ``clear_cache`` to your
``INSTALLED_APPS`` setting:
``` python
INSTALLED_APPS = (
# ...
'clear_cache',
)
```
## Usage
To clear your cache, simply run the ``clear_cache`` management command:
``` bash
$ python manage.py clear_cache
Your cache has been cleared!
```
**NOTE**: This will only (obviously) work if you've got a cache configured (eg:
memcached, local memory, etc.). If you have no idea what I'm talking about,
read through the [official Django caching docs](https://docs.djangoproject.com/en/dev/topics/cache/?from=olddocs).
## Tests
[![Build Status](https://secure.travis-ci.org/rdegges/django-clear-cache.png?branch=master)](http://travis-ci.org/rdegges/django-clear-cache)
Want to run the tests? No problem:
``` bash
$ git clone git://github.com/rdegges/django-clear-cache.git
$ cd django-clear-cache
$ python setup.py develop
...
$ python manage.py test clear_cache
Creating test database for alias 'default'...
.Your cache has been cleared!
..
----------------------------------------------------------------------
Ran 3 tests in 1.007s
OK
Destroying test database for alias 'default'...
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-clear-cache-0.2.tar.gz
(163.7 kB
view details)
File details
Details for the file django-clear-cache-0.2.tar.gz
.
File metadata
- Download URL: django-clear-cache-0.2.tar.gz
- Upload date:
- Size: 163.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6196e93ddb5d762605e870f8c2b2ee8c5d326ad5d608c9a796427decfd17c3d |
|
MD5 | 97b9caecd9f2b646fa7825a88842d8d6 |
|
BLAKE2b-256 | c0b7947eda80f93d01613e4fedff0a83b171cab423140f55faaae3de8a3d6a70 |