| 172 | # self.cursor.execute("CREATE INDEX IF NOT EXISTS idx_key ON cache (key)") |
| 173 | |
| 174 | def pull(self, key: str) -> Union[CacheResponse, None]: |
| 175 | self.ensure_connection() |
| 176 | with self.connection: |
| 177 | cache = self.cursor.execute( |
| 178 | "SELECT value FROM cache WHERE key = :0", {"0": key} |
| 179 | ).fetchone() |
| 180 | if cache: |
| 181 | logger.debug("Value found in DB, returning it") |
| 182 | return CacheResponse(key, cache[0]) |
| 183 | else: |
| 184 | logger.debug(f"No value found for key: {key}") |
| 185 | return None |
| 186 | |
| 187 | def push(self, key: str, value: Union[str, dict]) -> None: |
| 188 | if isinstance(value, dict): |