public Task <Client> FindClientByIdAsync(string clientId) { var client = _clientDB.FindClientById(clientId); _logger.LogDebug("{clientId} found in database: {clientIdFound}", clientId, client != null); return(Task.FromResult <Client>(client)); }
public Task <Client> FindClientByIdAsync(string clientId) { var client = _cache.Get <Client>("clients." + clientId); if (client == null) { lock (locker) { client = _cache.Get <Client>("clients." + clientId); if (client != null) { return(Task.FromResult <Client>(client)); } client = _clientDB.FindClientById(clientId); _logger.LogDebug("{clientId} found in database: {clientIdFound}", clientId, client != null); if (client != null) { _cache.Set <Client>("clients." + clientId, client, TimeSpan.FromMinutes(5)); } } } return(Task.FromResult <Client>(client)); }
private static void EnsureSeedClientData(IClientProvider clientProvider) { if (clientProvider != null) { Console.WriteLine("Clients being populated"); foreach (var client in Clients.Get().ToList()) { if (clientProvider.FindClientById(client.ClientId) == null) { clientProvider.Add(client); } } } else { Console.WriteLine("Clients already populated"); } }