'Count the number of one time keys the server has for a device
Returns:
Dict mapping from algorithm to number of keys for that algorithm.'

@cached(max_entries=10000)
def count_e2e_one_time_keys(self, user_id, device_id):

    def _count_e2e_one_time_keys(txn):
        sql = 'SELECT    algorithm,    COUNT(key_id)    FROM    e2e_one_time_keys_json    WHERE    user_id    =    ?    AND    device_id    =    ?    GROUP    BY    algorithm'
        txn.execute(sql, (user_id, device_id))
        result = {}
        for (algorithm, key_count) in txn:
            result[algorithm] = key_count
        return result
    return self.runInteraction('count_e2e_one_time_keys', _count_e2e_one_time_keys)
