class AnguisRedis(AnguisBase): def __init__(self, host='localhost', port=6379, db=0, *args, **kwargs): self.r = Redis(host, port, db) super(AnguisRedis, self).__init__() def __del__(self): super(AnguisRedis, self).__del__() def __getitem__(self, key): return self.unserialize(self.r.get(key)) def __setitem__(self, key, obj): self.r.set(key, self.serialize(obj)) def __delitem__(self, key): return self.r.delete(key) def __iter__(self): return iter(self.r.keys()) def __len__(self): return len(self.r.keys())
redis_port = 6379 redis_password = '******' # redis_password = '******' ssl_enabled = False # ssl_enabled = True redis_client = Redis(host=redis_url, port=6379, db=0, password=redis_password, ssl=ssl_enabled, socket_timeout=10, connection_pool=None, charset='utf-8', errors='strict', unix_socket_path=None) print("Keys in redis at the beginning") redis_keys = redis_client.keys('auth:*') for key in redis_keys: print(key) for key in redis_keys: redis_client.delete(key) # print('Deleted key: %s' % key) print("Script executed successfully")
def delete_all(): red = Redis() for key in red.keys(): red.delete(key)
if __name__ == '__main__': s: str = 'C:\\Users\\LuomingPC\\PythonRepo\\bilibiliSpider\\data-temp\\2019-12-24_21-46-18\\danmaku\\73933928-126446422-1577195272634283100.xml' s = s.replace('\\', '/') i = s.find('data-temp') print(str(s[i:]).replace('data-temp/', '')) exit(0) # import os # print(os.listdir('../data-temp/')) # exit(90) # for key in red.keys('program-temp-*'): # red.delete(key) # exit(0) id = 25241424977985538 count = 0 for key in red.keys(): value = None if red.type(key) == b'set': value = red.smembers(key) if red.type(key) == b'list': value = red.lrange(key, 0, -1) count += len(value) # for item in value: # item = int(item) # if item == id: # print(key) print(count) exit(0) l1 = [1, 2, 3, 4, 9, 10, 11, 12] l2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] for item1 in l1: