Esempio n. 1
0
        protected virtual async Task <PermissionGrantCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey)
        {
            var cacheKey  = CalculateCacheKey(name, providerName, providerKey);
            var cacheItem = await Cache.GetAsync <PermissionGrantCacheItem>(cacheKey);

            if (cacheItem != null)
            {
                return(cacheItem);
            }

            cacheItem = new PermissionGrantCacheItem(name, await _context.PermissionGrants.AnyAsync(
                                                         p => p.Name == name &&
                                                         p.ProviderName == providerName &&
                                                         p.ProviderKey == providerKey));

            await Cache.SetAsync(cacheKey, cacheItem);

            return(cacheItem);
        }
Esempio n. 2
0
 protected virtual string CalculateCacheKey(string name, string providerName, string providerKey)
 {
     return(PermissionGrantCacheItem.CalculateCacheKey(name, providerName, providerKey));
 }