MarioYC

erase_repeated_blogs

Feb 12th, 2013
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. # -*- coding:utf-8 -*-
  2. import redis
  3.  
  4. from django.core.management.base import BaseCommand
  5.  
  6.  
  7. BLOG_LIST_KEY = 'mula2_blogs'
  8.  
  9.  
  10. class Command(BaseCommand):
  11.     def handle(self, *args, **kwargs):
  12.         # redis para blogs
  13.         R = redis.StrictRedis('', 6379)
  14.         blogs = set()
  15.  
  16.         while True:
  17.             blog = R.lpop(BLOG_LIST_KEY)
  18.             if blog is None:
  19.                 break
  20.             else:
  21.                 blogs.add(blog)
  22.  
  23.         for blog in blogs:
  24.             R.lpush(BLOG_LIST_KEY, blog)
Advertisement
Add Comment
Please, Sign In to add comment