TIMEX
TIMEX

Reputation: 271874

In Django, how to clear all the memcached keys and values?

I don't want to restart the memcached server!

Upvotes: 23

Views: 14448

Answers (3)

huseyin39
huseyin39

Reputation: 1403

An easiest and fastest way:

echo flush_all > /dev/tcp/localhost/11211

Upvotes: 1

Wtower
Wtower

Reputation: 19902

And an one-liner from console:

echo "from django.core.cache import cache; cache._cache.flush_all()" | ./manage.py shell [--settings=myapp.settings_live]

Upvotes: 2

shanyu
shanyu

Reputation: 9716

from django.core.cache import cache
cache._cache.flush_all()

Also see this ticket, it has a patch (that I haven't tested) to flush any type of cache backend: http://code.djangoproject.com/ticket/11503

Upvotes: 42

Related Questions