synapse/storage/state.py
def _get_some_state_from_cache(self, group, types):
        """Checks if group is in cache. See `_get_state_for_groups`

        Returns 3-tuple (`state_dict`, `missing_types`, `got_all`).
        `missing_types` is the list of types that aren't in the cache for that
        group. `got_all` is a bool indicating if we successfully retrieved all
        requests state from the cache, if False we need to query the DB for the
        missing state.

        Args:
            group: The state group to lookup
            types (list): List of 2-tuples of the form (`type`, `state_key`),
                where a `state_key` of `None` matches all state_keys for the
                `type`.
        """
        is_all, known_absent, state_dict_ids = self._state_group_cache.get(group)

        type_to_key = {}
        missing_types = set()

        for typ, state_key in types:
            key = (typ, state_key)
            if state_key is None:
                type_to_key[typ] = None
                missing_types.add(key)
            else:
                if type_to_key.get(typ, object()) is not None:
                    type_to_key.setdefault(typ, set()).add(state_key)

                if key not in state_dict_ids and key not in known_absent:
                    missing_types.add(key)

        sentinel = object()

        def include(typ, state_key):
            valid_state_keys = type_to_key.get(typ, sentinel)
            if valid_state_keys is sentinel:
                return False
            if valid_state_keys is None:
                return True
            if state_key in valid_state_keys:
                return True
            return False

        got_all = is_all or not missing_types

        return {
            k: v for k, v in state_dict_ids.iteritems()
            if include(k[0], k[1])
        }, missing_types, got_all
Checks if group is in cache. See `_get_state_for_groups`

        Returns 3-tuple (`state_dict`, `missing_types`, `got_all`).
        `missing_types` is the list of types that aren't in the cache for that
        group. `got_all` is a bool indicating if we successfully retrieved all
        requests state from the cache, if False we need to query the DB for the
        missing state.

        Args:
            group: The state group to lookup
            types (list): List of 2-tuples of the form (`type`, `state_key`),
                where a `state_key` of `None` matches all state_keys for the
                `type`.
        
Checks if group is in cache.
Checks if group is in cache .
def _get_some_state_from_cache(self, group, types):
        is_all, known_absent, state_dict_ids = self._state_group_cache.get(group)
        type_to_key = {}
        missing_types = set()
        for typ, state_key in types:
            key = (typ, state_key)
            if state_key is None:
                type_to_key[typ] = None
                missing_types.add(key)
            else:
                if type_to_key.get(typ, object()) is not None:
                    type_to_key.setdefault(typ, set()).add(state_key)
                if key not in state_dict_ids and key not in known_absent:
                    missing_types.add(key)
        sentinel = object()
        def include(typ, state_key):
            valid_state_keys = type_to_key.get(typ, sentinel)
            if valid_state_keys is sentinel:
                return False
            if valid_state_keys is None:
                return True
            if state_key in valid_state_keys:
                return True
            return False
        got_all = is_all or not missing_types
        return {
            k: v for k, v in state_dict_ids.iteritems()
            if include(k[0], k[1])
        }, missing_types, got_all
def _get_some_state_from_cache ( self , group , types ) : is_all , known_absent , state_dict_ids = self . _state_group_cache . get ( group ) type_to_key = { } missing_types = set ( ) for typ , state_key in types : key = ( typ , state_key ) if state_key is None : type_to_key [ typ ] = None missing_types . add ( key ) else : if type_to_key . get ( typ , object ( ) ) is not None : type_to_key . setdefault ( typ , set ( ) ) . add ( state_key ) if key not in state_dict_ids and key not in known_absent : missing_types . add ( key ) sentinel = object ( ) def include ( typ , state_key ) : valid_state_keys = type_to_key . get ( typ , sentinel ) if valid_state_keys is sentinel : return False if valid_state_keys is None : return True if state_key in valid_state_keys : return True return False got_all = is_all or not missing_types return { k : v for k , v in state_dict_ids . iteritems ( ) if include ( k [ 0 ] , k [ 1 ] ) } , missing_types , got_all
Checks if group is in cache.
Checks if group is in cache .
"""Checks if group is in cache. See `_get_state_for_groups`

        Returns 3-tuple (`state_dict`, `missing_types`, `got_all`).
        `missing_types` is the list of types that aren't in the cache for that
        group. `got_all` is a bool indicating if we successfully retrieved all
        requests state from the cache, if False we need to query the DB for the
        missing state.

        Args:
            group: The state group to lookup
            types (list): List of 2-tuples of the form (`type`, `state_key`),
                where a `state_key` of `None` matches all state_keys for the
                `type`.
        """
self
group
The state group to lookup
The state group to lookup
types
List of 2-tuples of the form (`type`, `state_key`),
where a `state_key` of `None` matches all state_keys for the
`type`.
List of 2 - tuples of the form ( ` type ` ` state_key ` ) where a ` state_key ` of ` None ` matches all state_keys for the ` type ` .