Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions scripts/optimize-conversion-engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import hashlib
from dataclasses import dataclass
from functools import lru_cache, wraps
import pickle
import gzip

# Add paths for imports
Expand Down Expand Up @@ -58,7 +57,7 @@ def cache_file_result(self, cache_key: str, result: Any, ttl_seconds: int = 3600
}

with gzip.open(cache_file, 'wb') as f:
pickle.dump(cache_data, f)
f.write(json.dumps(cache_data).encode('utf-8'))

def get_cached_file_result(self, cache_key: str) -> Optional[Any]:
"""Retrieve cached file result if valid"""
Expand All @@ -69,7 +68,7 @@ def get_cached_file_result(self, cache_key: str) -> Optional[Any]:

try:
with gzip.open(cache_file, 'rb') as f:
cache_data = pickle.load(f)
cache_data = json.loads(f.read().decode('utf-8'))

# Check if cache is still valid
if time.time() - cache_data["timestamp"] > cache_data["ttl"]:
Expand Down