async def _set(self, *args: dict, **kwargs: dict): key = self.__build_key(*args, **kwargs) if bredis.exists(key): value = pickle.loads(bredis.get(key)) return value if type(value) is not _NotSet else value.real_value result = await self.func(*args, **kwargs) if result is None: result = _NotSet() asyncio.ensure_future(set_value(key, result, ttl=self.ttl)) log.debug(f"Cached: writing new data for key - {key}") return result if type(result) is not _NotSet else result.real_value
def get_flood(self, message) -> Optional[CacheModel]: if data := bredis.get(self.cache_key(message)): data = pickle.loads(data) return data
def get_state(self, message: Message): return bredis.get(self.state_cache_key.format(chat_id=message.chat.id))
async def get_admins_rights(chat_id, force_update=False): key = 'admin_cache:' + str(chat_id) if (alist := bredis.get(key)) and not force_update: return pickle.loads(alist)