private async Task <DateTime?> TryGetPlayerLastLoginTime(string characterId, DateTime?storeLoginTime) { var loginKey = PlayerLoginMemoryCache.GetPlayerLoginKey(characterId); if (!_loginCache.TryGetValue(loginKey, out DateTime cacheEntry)) { var resolvedLoginTime = await ResolvePlayerLastLoginTime(characterId, storeLoginTime); if (resolvedLoginTime == null) { return(null); } cacheEntry = (DateTime)resolvedLoginTime; var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSize(1) .SetSlidingExpiration(TimeSpan.FromMinutes(15)); _loginCache.Set(loginKey, cacheEntry, cacheEntryOptions); } return(cacheEntry); }
public PlayerLeaderboardController(IDbContextHelper dbContextHelper, ICharacterService characterService, PlayerLoginMemoryCache loginCache) { _dbContextHelper = dbContextHelper; _characterService = characterService; _loginCache = loginCache.Cache; }
public PlayerDetailsController(ICharacterService characterService, IDbContextHelper dbContextHelper, PlayerLoginMemoryCache loginCache) { _characterService = characterService; _dbContextHelper = dbContextHelper; _loginCache = loginCache.Cache; }