Abp.Runtime.Caching.CacheBase.SetAsync(string, object, System.TimeSpan)

Here are the examples of the csharp api class Abp.Runtime.Caching.CacheBase.SetAsync(string, object, System.TimeSpan) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: ABP
Source File: CacheBase.cs
View license
public virtual async Task<object> GetAsync(string key, Func<Task<object>> factory)
        {
            var cacheKey = key;
            var item = await GetOrDefaultAsync(key);
            if (item == null)
            {
                using (await _asyncLock.LockAsync())
                {
                    item = await GetOrDefaultAsync(key);
                    if (item == null)
                    {
                        item = await factory();
                        await SetAsync(cacheKey, item);
                    }
                }
            }

            return item;
        }