优雅删除百万级别 Hash 脚本
#!/user/bin/python
import redis
redis_host = 'localhost'
redis_port = 6379
big_hash_key = 'big_redis_hash_key'
print(big_hash_key, 'length:', r.hlen(big_hash_key))
r = redis.Redis(host=redis_host, port=redis_port)
for item in r.hscan_iter(big_hash_key, count=100):
print('del: ', item[0])
r.hdel(big_hash_key, item[0])