示例#1
0
 public Task <IAppEntity?> GetAppAsync(string appName)
 {
     return(localCache.GetOrCreateAsync($"GetAppAsync({appName})", async() =>
     {
         return await indexForApps.GetAppByNameAsync(appName);
     }));
 }
示例#2
0
        public async Task <IAppEntity?> GetAppAsync(string appName, bool canCache = false)
        {
            var app = await localCache.GetOrCreateAsync(AppCacheKey(appName), () =>
            {
                return(indexForApps.GetAppByNameAsync(appName, canCache));
            });

            if (app != null)
            {
                localCache.Add(AppCacheKey(app.Id), app);
            }

            return(app?.IsArchived == true ? null : app);
        }
示例#3
0
        public async Task <IAppEntity?> GetAppAsync(string appName, bool canCache = false)
        {
            var cacheKey = AppCacheKey(appName);

            if (localCache.TryGetValue(cacheKey, out var cached) && cached is IAppEntity found)
            {
                return(found);
            }

            var app = await indexForApps.GetAppByNameAsync(appName, canCache);

            if (app != null)
            {
                localCache.Add(cacheKey, app);
                localCache.Add(AppCacheKey(app.Id), app);
            }

            return(app);
        }