示例#1
0
        public async Task SetCacheAsync <T>(string cacheKey, T value, int cacheTimeoutInMinutes = 0)
        {
            try {
                await Cache.StringSetAsync(cacheKey, value.ToString());

                if (cacheTimeoutInMinutes != 0)
                {
                    await Cache.KeyExpireAsync(cacheKey, TimeSpan.FromMinutes(cacheTimeoutInMinutes));
                }
            }
            catch (Exception) {
                throw new CacheException("An error occured while setting the cache.");
            }
        }