From 5bb577d50fda0442635f254bf9fc25f1a7700295 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 30 Jun 2024 18:39:55 +0000 Subject: [PATCH] cellidresolver: cache lookup results in memory it can take literally 5s or more on moby to synthesize cell results. caching will hopefully help that. --- ols/resolver/cellid/cellidresolver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ols/resolver/cellid/cellidresolver.py b/ols/resolver/cellid/cellidresolver.py index c9c09e8..1547a4a 100644 --- a/ols/resolver/cellid/cellidresolver.py +++ b/ols/resolver/cellid/cellidresolver.py @@ -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,