MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / _cache_diversity_value

Method _cache_diversity_value

data/database.py:2155–2164  ·  view source on GitHub ↗

Cache a diversity value with LRU eviction

(self, code_hash: int, diversity: float)

Source from the content-addressed store, hash-verified

2153 )
2154
2155 def _cache_diversity_value(self, code_hash: int, diversity: float) -> None:
2156 """Cache a diversity value with LRU eviction"""
2157 # Check if cache is full
2158 if len(self.diversity_cache) >= self.diversity_cache_size:
2159 # Remove oldest entry
2160 oldest_hash = min(self.diversity_cache.items(), key=lambda x: x[1]["timestamp"])[0]
2161 del self.diversity_cache[oldest_hash]
2162
2163 # Add new entry
2164 self.diversity_cache[code_hash] = {"value": diversity, "timestamp": time.time()}
2165
2166 def _invalidate_diversity_cache(self) -> None:
2167 """Invalidate the diversity cache when programs change significantly"""

Callers 1

_get_cached_diversityMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected