Skip to content

Commit 3b109c6

Browse files
committed
fix: remove auto-save from put() to prevent test hanging
The test_cache_memory_limit test was adding 10,000 entries, each triggering a file write. This caused the CI to hang for 2+ hours. Now save_cache() must be called explicitly after batch operations.
1 parent 01effa3 commit 3b109c6

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

demo_cache_persistence.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def demo_cache_persistence():
3939
cache1.put(query, result)
4040
time.sleep(0.1) # Simulate processing time
4141

42+
# Save cache after adding all entries
43+
cache1.save_cache()
44+
4245
stats1 = cache1.get_cache_stats()
4346
print(f"\n📊 Cache populated: {stats1['total_entries']} entries")
4447
print(f" Cache file: {stats1['cache_file']}")

nexum_ai/optimizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ def put(self, query: str, result: str) -> None:
9494
'result': result
9595
})
9696
print(f"Cached query: {query[:50]}...")
97-
98-
# Auto-save cache after adding new entry
99-
self.save_cache()
10097

10198
def clear(self) -> None:
10299
"""Clear the cache"""
@@ -346,6 +343,9 @@ def test_cache_persistence() -> Dict[str, Any]:
346343
for query, result in test_queries:
347344
cache1.put(query, result)
348345

346+
# Save cache after adding entries
347+
cache1.save_cache()
348+
349349
stats1 = cache1.get_cache_stats()
350350
print(f"Cache stats after adding entries: {stats1}")
351351

test_cache_integration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def test_cache_persistence_lifecycle():
3939
for query, result in test_data:
4040
cache1.put(query, result)
4141

42+
# Save cache after adding entries
43+
cache1.save_cache()
44+
4245
stats1 = cache1.get_cache_stats()
4346
print(f" ✅ Added {stats1['total_entries']} entries")
4447

@@ -113,6 +116,7 @@ def test_environment_variable_config():
113116
# Create cache (should use env variable)
114117
cache = SemanticCache()
115118
cache.put("SELECT 1", "test result")
119+
cache.save_cache()
116120

117121
# Verify it used the custom path
118122
assert os.path.exists(custom_cache), "Should use environment variable path"

0 commit comments

Comments
 (0)