get method

List<double>? get(
  1. String functionId,
  2. String contentHash
)

Gets embedding for a function, or null if not cached or invalidated.

Returns null if:

  • Function is not in cache
  • Content hash has changed (code was modified)

ADR-016 1.1: Uses O(1) LinkedHashMap operations for LRU.

Implementation

List<double>? get(String functionId, String contentHash) {
  // O(1) remove - returns the entry if it exists
  final entry = _cache.remove(functionId);
  if (entry == null) return null;

  // Check if content has changed
  if (entry.contentHash != contentHash) {
    // Stale entry, don't re-add
    return null;
  }

  // O(1) add to end (most recently used)
  _cache[functionId] = entry;

  return entry.embedding;
}