Exemplo n.º 1
0
        private static T GetUsingCas <T>(IDistributedServiceCache cache, ServiceCacheRegistration registration, object tag, object[] values, string name, string @namespace, bool useDBNull)
        {
            CacheItemHeader header;
            var             valueAsCache = cache.Get(tag, name, registration, out header);

            if (valueAsCache != null && (!registration.UseHeaders || header != null))
            {
                return(!useDBNull || !(valueAsCache is DBNull) ? (T)valueAsCache : default(T));
            }
            // create
            var value = CreateData <T>(@namespace, registration, tag, values, out header);

            valueAsCache = (!useDBNull || value != null ? (object)value : DBNull.Value);
            cache.Add(tag, name, registration.ItemPolicy, valueAsCache, new ServiceCacheByDispatcher(registration, values, header));
            return(value);
        }
Exemplo n.º 2
0
        private static void SetUsingCas(IDistributedServiceCache cache, ServiceCacheRegistration registration, object tag, CacheItemHeader header, bool useDBNull, object value)
        {
            var valueAsCache = (!useDBNull || value != null ? (object)value : DBNull.Value);

            cache.Add(tag, header.Item, registration.ItemPolicy, valueAsCache, new ServiceCacheByDispatcher(registration, header.Values, header));
        }