put method

void put(
  1. String functionId,
  2. String contentHash,
  3. List<double> embedding
)

Stores embedding for a function.

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

Implementation

void put(String functionId, String contentHash, List<double> embedding) {
  // O(1) remove if already exists (to update position)
  _cache.remove(functionId);

  // O(1) evict oldest entries if at capacity
  while (_cache.length >= _maxEntries && _cache.isNotEmpty) {
    _cache.remove(_cache.keys.first);
  }

  // O(1) add to end (most recently used)
  _cache[functionId] = _CacheEntry(
    contentHash: contentHash,
    embedding: List.unmodifiable(embedding),
  );
}