def contacts(self, user: ID) -> List[ID]: # try from memory cache array = self.__contacts.get(user) if array is None: # try from local storage path = self.__contacts_path(identifier=user) self.info('Loading contacts from: %s' % path) text = self.read_text(path=path) if text is None: array = [] else: array = ID.convert(members=text.splitlines()) # store into memory cache self.__contacts[user] = array return array
def members(self, group: ID) -> List[ID]: # 1. try from memory cache array = self.__members.get(group) if array is None: # 2. try from local storage path = self.__members_path(identifier=group) self.info('Loading members from: %s' % path) text = self.read_text(path=path) if text is None: array = [] else: array = ID.convert(members=text.splitlines()) # 3. store into memory cache self.__members[group] = array return array
def users(self) -> Optional[List[ID]]: if self.__users is None: array = self.get('users') if isinstance(array, list): self.__users = ID.convert(members=array) return self.__users
def mute_list(self) -> Optional[List[ID]]: array = self.get('list') if array is not None: return ID.convert(members=array)