Exemplo n.º 1
0
        public object GetResourceSet(ResourceQueryHandle input)
        {
            CultureInfo currentCulture = new CultureInfo(input.Culture);
            var         key            = new List <object> {
                input.Culture, input.Id, input.Treatment
            }
            .AsReadOnly().GetSequenceHashCode();
            var newValue = new Lazy <object>(() =>
            {
                return(GetResourceSet(input.Id, input.Treatment, currentCulture));
            });
            var value = _cache.GetOrCreate(key.ToString(CultureInfo.InvariantCulture), entry =>
            {
                entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(100);
                return(newValue);
            });

            var result = value != null ? value.Value : newValue.Value;

            return(result);
        }
Exemplo n.º 2
0
        public Task <object> GetResourceSetAsync(ResourceQueryHandle input)
        {
            var result = Task.Run(() => GetResourceSet(input));

            return(result);
        }