redis collection
- SADD key member1 [member2] # to add a collection of one or more members
- SDIFF key1 [key2] # Returns all differences for a given set of Assembly, key2 not return the entire set key1
- SMEMBERS key # return all the members of the collection
- SPOP key # removes and returns a random element in the set
- SRANDMEMBER key [count] # Returns the data set a plurality of random numbers or returned without removing
redis affairs:
- MULTI # transaction begins
- EXEC # submit things
- DISCARD # cancel things
After things started to query the data will not return
from rediscluster import StrictRedisCluster
import redis
from common.common_wckjenv import logger
def wckjRedisCluster(): #StrictRedis
startup_nodes = [
{"host": "10.10.2.67","port": "6379"},
]
r = StrictRedisCluster(startup_nodes=startup_nodes,password="a123456")
#r.on_
#r.execute_command("auth", "a123456")
r.sdiff("xjb:cit:product:sku:0:1")
class MyRedis(redis.Redis):
def __init__(self):
super(MyRedis, self).__init__(host='10.10.2.67', port=6379, db=0, password="a123456")
if __name__ == "__main__":
A =MyRedis()
data_key = "xjb:cit:product:sku:0:1"
data = A.sdiff(data_key)
logger.info(data)
data = A.spop(data_key)
logger.info(data)
data = A.sdiff(data_key)
logger.info(data)