Skip to content

Instantly share code, notes, and snippets.

@thoas
Created January 10, 2013 08:00
Show Gist options
  • Save thoas/4500306 to your computer and use it in GitHub Desktop.
Save thoas/4500306 to your computer and use it in GitHub Desktop.
import telnetlib
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'madmoizelle.settings'
from django.conf import settings
from django.core.cache import cache
host = '127.0.0.1'
port = 11211
t = telnetlib.Telnet(host, port)
t.write('stats cachedump 3 10000 END\n')
items = t.read_until('END').split('\r\n')
for item in items:
if item.startswith('ITEM :1:sorl-thumbnail'):
cmd = 'delete %s\n' % item[5:63]
t.write(cmd)
print cmd
print t.read_some()
elif item.startswith('ITEM :1:eros_'):
cmd = 'delete %s\n' % item[5:41]
t.write(cmd)
print cmd
print t.read_some()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment