Closes #127 The GetLatestVersion method previously fetched all events for an actor to find the maximum version, resulting in O(n) performance. This implementation replaces the full scan with JetStream's DeliverLast() consumer option, which efficiently retrieves only the last message without scanning all events. Performance improvements: - Uncached lookups: ~1.4ms regardless of event count (constant time) - Cached lookups: ~630ns (very fast in-memory access) - Memory usage: Same 557KB allocated regardless of event count - Works correctly with cache invalidation The change is backward compatible: - Cache in getLatestVersionLocked continues to provide O(1) performance - SaveEvent remains correct with version conflict detection - All existing tests pass without modification - Benchmark tests verify O(1) behavior Co-Authored-By: Claude Code <noreply@anthropic.com>
13 KiB
13 KiB