cellidresolver: cache lookup results in memory

it can take literally 5s or more on moby to synthesize cell results. caching will hopefully help that.
This commit is contained in:
2024-06-30 18:39:55 +00:00
parent 2caacd27a6
commit 5bb577d50f

View File

@@ -2,6 +2,7 @@ import logging
import os.path
import sqlite3
from datetime import datetime
from functools import lru_cache
from typing import Optional
from ..base import ResolverBase
@@ -36,6 +37,7 @@ class CellIdResolver(ResolverBase):
cur = self.con.cursor()
return cur.execute('PRAGMA user_version').fetchone()[0]
@lru_cache
def search_network(self, radiotype, mcc, net, area, cell) -> Optional[dict]:
cur = self.con.cursor()
# radiotype is not required in observations
@@ -56,6 +58,7 @@ class CellIdResolver(ResolverBase):
else:
return None
@lru_cache
def search_nearby(self, radiotype, mcc, net, area, cell) -> Optional[dict]:
"""
synthesize a cell tower from towers whose `cell` id is close to the id of interest,