Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

refactor: Use JSON column type for SearchCache results

LearningCircuitd3ec2b98eee2
diff --git a/src/local_deep_research/database/models/cache.py b/src/local_deep_research/database/models/cache.py
index 1b72dedcea..0c2f466a83 100644
--- a/src/local_deep_research/database/models/cache.py
+++ b/src/local_deep_research/database/models/cache.py
@@ -73,7 +73,9 @@ class SearchCache(Base):
query_hash = Column(String, primary_key=True)
query_text = Column(Text, nullable=False)
- results = Column(Text, nullable=False) # JSON string
+ results = Column(
+ JSON, nullable=False
+ ) # JSON column for automatic serialization
created_at = Column(Integer, nullable=False) # Unix timestamp
expires_at = Column(Integer, nullable=False) # Unix timestamp
access_count = Column(Integer, default=1)
diff --git a/src/local_deep_research/utilities/search_cache.py b/src/local_deep_research/utilities/search_cache.py
index 3673b4ca27..f1c5f16d73 100644
--- a/src/local_deep_research/utilities/search_cache.py
+++ b/src/local_deep_research/utilities/search_cache.py
@@ -5,7 +5,6 @@ Includes TTL, LRU eviction, and query normalization.
"""
import hashlib
-import json
import time
from functools import lru_cache
from pathlib import Path
@@ -164,7 +163,7 @@ class SearchCache:
)
if cache_entry:
- results = json.loads(cache_entry.results)
+ results = cache_entry.results
# Update access statistics
cache_entry.access_count += 1
@@ -219,8 +218,6 @@ class SearchCache:
expires_at = current_time + (ttl or self.default_ttl)
try:
- results_json = json.dumps(results)
-
# Store in database
session = self.Session()
try:
@@ -234,7 +231,7 @@ class SearchCache:
if existing:
# Update existing entry
existing.query_text = self._normalize_query(query)
- existing.results = results_json
+ existing.results = results
existing.created_at = current_time
existing.expires_at = expires_at
existing.access_count = 1
@@ -244,7 +241,7 @@ class SearchCache:
cache_entry = SearchCacheModel(
query_hash=query_hash,
query_text=self._normalize_query(query),
- results=results_json,
+ results=results,
created_at=current_time,
expires_at=expires_at,
access_count=1,