Beispiel #1
0
 public void Add(string key, object value, TimeSpan slidingExpiration, CacheItemRemovedCallback cacheRemove)
 {
     string cacheKey = CacheKey(key, _hashkey);
     lock (GetLock(cacheKey, TimeSpan.Zero, slidingExpiration, null, this))
     {
         object local = NCache.Get(cacheKey);
         if (local == null)
             local = NHashtable.InternalCallback(cacheKey);
     }
 }
Beispiel #2
0
        public object Get(string key)
        {
            string cacheKey = NHashtable.CacheKey(key, _hashkey);

            object obj = base[cacheKey];

            CacheEntry entry = null;
            if (CacheLockbox.TryGetCacheEntry(cacheKey, out entry))
            {
                lock (CacheLockbox.GetLock(cacheKey))
                {
                    object local = NCache.Get(cacheKey);
                    if (local == null)
                        local = NHashtable.InternalCallback(cacheKey);
                    return local;
                }
            }
            return obj;
        }