1.python操作redis-zset
REDIS_HOST = "10.133.3.26" REDIS_PORT = 6379 REDIS_PASSWORK = "" REDIS_DB = 3 from redis import ConnectionPool, StrictRedis pool = ConnectionPool(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, # password=REDIS_PASSWORK,) ) conn = StrictRedis(connection_pool=pool) conn.zadd('appSellers', 1, 'jiang') # 向有顺集合中增加一个元素jiang、它的分值为1 conn.zscore('appSellers', 'jiang') # 获取jiang这个元素的分值 newScore = conn.zrange('appSellers', 0, -1, desc=True, withscores=True) # 获取集合中指定序列内的元素 newScore = conn.zrangebyscore('appSellers', 80, 100) # 获取指定分数范围内的元素 newScore = conn.zincrby('appSellers', 'wolson', 10) # 增加指定元素的分值 newScore = conn.zcard('appSellers') # 获取集合中的元素数 newScore = conn.zcount('appSellers', 90, 101) # 获取分数范围内的元素数量 conn.zrem('appSellers', 'wolson') # 删除集合中指定元素 conn.zremrangebyscore('appSellers', 1, 20000) # 删除集合中指定期间分值的元素