Filter database key by pattern
        :param key_pattern: pattern (either glob or regex)
        :param is_regex: should be True if the pattern is regex
        :return: iterator of (key, value) pairs

def filter(self, key_pattern='*', is_regex=False):
        """
        Filter database key by pattern
        :param key_pattern: pattern (either glob or regex)
        :param is_regex: should be True if the pattern is regex
        :return: iterator of (key, value) pairs
        """
        if is_regex:
            if isinstance(key_pattern, str):
                regex = re.compile(key_pattern)
            else:
                regex = key_pattern
        else:
            regex = None
        for k, v in self.items():
            if regex and regex.match(k) or (not regex) and fnmatch(k, key_pattern):
                yield k, v