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

            Logger.LogDebug($"PermissionStore.GetCacheItemAsync: {cacheKey}");

            var cacheItem = await Cache.GetAsync(cacheKey);

            if (cacheItem != null)
            {
                Logger.LogDebug($"Found in the cache: {cacheKey}");
                return(cacheItem);
            }

            Logger.LogDebug($"Not found in the cache, getting from the repository: {cacheKey}");

            cacheItem = new PermissionGrantCacheItem(
                name,
                (await PermissionGrantRepository.FindAsync(name, providerName, providerKey)) != null
                );

            Logger.LogDebug($"Setting the cache item: {cacheKey}");

            await Cache.SetAsync(
                cacheKey,
                cacheItem
                );

            Logger.LogDebug($"Finished setting the cache item: {cacheKey}");

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