getSync method

User? getSync(
  1. UserID userId
)

Gets a user synchronously from cache, or returns null if not cached.

Updates the LRU access order when a user is found. Returns null if the user is not in the cache.

Implementation

User? getSync(UserID userId) {
  if (_cache.containsKey(userId)) {
    // Update LRU order
    _accessOrder.remove(userId);
    _accessOrder.add(userId);
    return _cache[userId];
  }
  return null;
}