Commit f55750ca authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Cache: Force JID objects

parent 197bcf47
Pipeline #9035 passed with stages
in 4 minutes and 17 seconds
......@@ -17,7 +17,6 @@
from typing import Any
from typing import NamedTuple
from typing import Optional
from typing import Union
import json
import time
......@@ -101,7 +100,7 @@ def __init__(self):
CACHE_SQL_STATEMENT)
self._entity_caps_cache: dict[tuple[str, str], DiscoInfo] = {}
self._disco_info_cache: dict[Union[JID, str], DiscoInfo] = {}
self._disco_info_cache: dict[JID, DiscoInfo] = {}
self._muc_cache: dict[JID, dict[str, Any]] = defaultdict(dict)
self._contact_cache: dict[JID, dict[str, Any]] = defaultdict(dict)
......@@ -181,7 +180,7 @@ def _clean_caps_table(self) -> None:
@timeit
def _fill_disco_info_cache(self) -> None:
sql = '''SELECT disco_info as "disco_info [disco_info]",
jid, last_seen FROM
jid as "jid [jid]", last_seen FROM
last_seen_disco_info'''
rows = self._con.execute(sql).fetchall()
for row in rows:
......@@ -190,7 +189,7 @@ def _fill_disco_info_cache(self) -> None:
log.info('%d DiscoInfo entries loaded', len(rows))
def get_last_disco_info(self,
jid: Union[str, JID],
jid: JID,
max_age: int = 0) -> Optional[DiscoInfo]:
"""
Get last disco info from jid
......@@ -210,7 +209,7 @@ def get_last_disco_info(self,
@timeit
def set_last_disco_info(self,
jid: Union[str, JID],
jid: JID,
disco_info: DiscoInfo,
cache_only: bool = False) -> None:
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment