getOrResolve method
Gets or resolves a user, updating the cache.
First checks the cache - if found, returns immediately. Otherwise, resolves the user using the provided callback, stores the result in the cache, and returns it.
Implementation
Future<User?> getOrResolve(
UserID userId,
ResolveUserCallback resolveUser,
) async {
// If in cache, return immediately
final cachedUser = getSync(userId);
if (cachedUser != null) {
return cachedUser;
}
// Resolve and update cache
final user = await resolveUser(userId);
_cacheUser(userId, user);
return user;
}