def print_key_value(self, event): """ 点击Listbox组件中一条缓存条目,查看对应数据 :param event: :return:None """ self.cache_content_text.delete('1.0', tk.END) #获取Listbox中选中的item的数据 key_info_list = self.cache_info_lb.get( self.cache_info_lb.curselection()).split(' ') key_id = key_info_list[0] key_type = key_info_list[1] third_value = key_info_list[2] #超时时间 or field_name(hash/set) redis = RedisUtil(int(self.db_index.get())) #如果数据类型是hash或者set,则在Listbox中显示hash或set的所有field if key_type in ['hash', 'set']: try: cache_info = redis.get_key_value(key_type, key_id, None) except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return self.fillin_listbox(key_type, key_id, cache_info) elif key_type in ['string', 'list', 'hash_field', 'set_field']: try: key_value = redis.get_key_value(key_type, key_id, third_value) except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return self.cache_content_text.insert(tk.INSERT, str(key_value))
def print_key_value(self,event): """ 点击Listbox组件中一条缓存条目,查看对应数据 :param event: :return:None """ self.cache_content_text.delete('1.0', tk.END) #获取Listbox中选中的item的数据 key_info_list = self.cache_info_lb.get(self.cache_info_lb.curselection()).split(' ') key_id = key_info_list[0] key_type = key_info_list[1] third_value = key_info_list[2] #超时时间 or field_name(hash/set) redis = RedisUtil(int(self.db_index.get())) #如果数据类型是hash或者set,则在Listbox中显示hash或set的所有field if key_type in ['hash','set']: try: cache_info = redis.get_key_value(key_type, key_id, None) except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return self.fillin_listbox(key_type, key_id, cache_info) elif key_type in ['string','list','hash_field','set_field']: try: key_value = redis.get_key_value(key_type, key_id, third_value) except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return self.cache_content_text.insert(tk.INSERT, str(key_value))
def query_cache_info(self): """ 按查询条件查询缓存 :return: """ if self.db_index.get() in self.all_db: redis = RedisUtil(int(self.db_index.get())) else: tk.messagebox.showerror('错误', '参数不正确:没有选择数据库') return type_variable_value = self.type_variable.get() query_condition_key = self.input_value.get() self.cache_content_text.delete('1.0', tk.END) self.cache_info_lb.delete(0, tk.END) #2.按指定的key类型和key名称查询数据 if type_variable_value in ['string','list','set','hash'] and \ self.check_none(query_condition_key): try: cache_info = redis.get_key_value(type_variable_value, query_condition_key, None) except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return #如果数据类型是hash或者set,则在Listbox中显示hash或set的所有field if type_variable_value in ['hash', 'set']: self.fillin_listbox(type_variable_value, query_condition_key, cache_info) return #如果数据类型是string,则在Text中显示value,在Listbox中显示key self.cache_info_lb.delete(0, tk.END) try: key_info_tuple = redis.get_key_info(query_condition_key) result = query_condition_key + ' ' + type_variable_value + ' 超时时间:' + key_info_tuple[ 1] except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return self.cache_info_lb.insert(tk.END, result) self.cache_content_text.insert(tk.INSERT, str(cache_info)) #1.查询当前数据库中所有的key信息:key名称、key类型、key超时时间,在Listbox组件显示 elif type_variable_value == '选择数据类型': try: cache_info = redis.get_all_keys() except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return for item in cache_info: self.tmp_list.clear() self.tmp_list.append(item) #临时保存数据 self.cache_info_lb.insert(tk.END, item)
def query_cache_info(self): """ 按查询条件查询缓存 :return: """ if self.db_index.get() in self.all_db: redis = RedisUtil(int(self.db_index.get())) else: tk.messagebox.showerror('错误', '参数不正确:没有选择数据库') return type_variable_value = self.type_variable.get() query_condition_key = self.input_value.get() self.cache_content_text.delete('1.0', tk.END) self.cache_info_lb.delete(0,tk.END) #2.按指定的key类型和key名称查询数据 if type_variable_value in ['string','list','set','hash'] and \ self.check_none(query_condition_key): try: cache_info = redis.get_key_value(type_variable_value, query_condition_key, None) except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return #如果数据类型是hash或者set,则在Listbox中显示hash或set的所有field if type_variable_value in ['hash','set']: self.fillin_listbox(type_variable_value, query_condition_key, cache_info) return #如果数据类型是string,则在Text中显示value,在Listbox中显示key self.cache_info_lb.delete(0,tk.END) try: key_info_tuple = redis.get_key_info(query_condition_key) result = query_condition_key+' '+type_variable_value+' 超时时间:'+key_info_tuple[1] except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return self.cache_info_lb.insert(tk.END, result) self.cache_content_text.insert(tk.INSERT, str(cache_info)) #1.查询当前数据库中所有的key信息:key名称、key类型、key超时时间,在Listbox组件显示 elif type_variable_value=='选择数据类型': try: cache_info = redis.get_all_keys() except ConnectionError: tk.messagebox.showerror('错误', '没有连接Redis') return for item in cache_info: self.tmp_list.clear() self.tmp_list.append(item) #临时保存数据 self.cache_info_lb.insert(tk.END, item)