コード例 #1
0
 public override void Put(byte[] key, Value val)
 {
     if (val == null)
     {
         this.Delete(key);
         return;
     }
     lock (this.writeLock)
     {
         CacheEntry <Value> curVal = null;
         if (this.cache.ContainsKey(key))
         {
             curVal = this.cache[key];
         }
         if (curVal == null)
         {
             curVal = this.CreateCacheEntry(val);
             CacheEntry <Value> oldVal = null;
             if (this.cache.ContainsKey(key))
             {
                 oldVal = this.cache[key];
             }
             this.cache[key] = curVal;
         }
         // assigning for non-counting cache only
         // for counting cache the value should be immutable (see HashedKeySource)
         curVal.value = val;
         curVal.Added();
     }
 }