Example #1
0
 public void hardSet(string id, Item data)
 {
     lock (db)
     {
         if (!db.ContainsKey (id))
         {
             db.Add(id, data);
             ulong s6 = data.getSize();
             size += s6;
             lock (l)
             {
                 globalSize += s6;
             }
             return;
         }
         ulong s = db[id].getSize();
         ulong s2 = data.getSize();
         lock (l)
         {
             globalSize += s2;
         }
         size += s2;
         size -= s;
         globalSize -= s;
         db[id].update = DateTime.Now;
         db[id] = data;
     }
 }
Example #2
0
 /// <summary>
 /// Replace the specified key and d.
 /// </summary>
 /// <param name="key">Key.</param>
 /// <param name="d">D.</param>
 public bool ReplaceCas(string key, Item d, double CAS)
 {
     lock (db)
     {
         if (db.ContainsKey (key))
         {
             if (db[key].cas == CAS)
             {
                 ulong s = db[key].getSize();
                 ulong s2 = d.getSize();
                 globalSize += s2;
                 size += s2;
                 size = size - s;
                 globalSize -= s;
                 db[key] = d;
                 db[key].update = DateTime.Now;
                 return true;
             }
         }
     }
     return false;
 }
Example #3
0
 /// <summary>
 /// Add the specified key.
 /// </summary>
 /// <param name="key">Key.</param>
 /// <param name="d">D.</param>
 public bool Add(string key, Item d)
 {
     lock (db)
     {
         if (!db.ContainsKey (key))
         {
             ulong s2 =d.getSize();
             size += s2;
             db.Add (key, d);
             globalSize += s2;
             return true;
         }
     }
     return false;
 }