public bool TryGetUserHasServerPermissions(string serverId, string token) { if (!_cache.TryGetValue(CacheKeys.CanEditGuild + token + serverId, out bool cacheResult)) { cacheResult = DiscordController.UserHasServerPermissions(serverId, token); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(System.TimeSpan.FromSeconds(60)); _cache.Set(CacheKeys.CanEditGuild + token + serverId, cacheResult, cacheEntryOptions); } return(cacheResult); }
public List <Guild> TryGetServersForUserFromCache(string accessToken) { if (!_cache.TryGetValue(CacheKeys.Guilds + accessToken, out List <Guild> cacheGuilds)) { //_client.GetGuildsAsync(CacheMode=CacheMode.AllowDownload,RequestOptions.Default) cacheGuilds = DiscordController.GetServersForUser(accessToken); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(System.TimeSpan.FromSeconds(60)); _cache.Set(CacheKeys.Guilds + accessToken, cacheGuilds, cacheEntryOptions); } return(cacheGuilds); }