Beispiel #1
0
 private void RenewEngine()
 {
     _Pool.Do(() =>
     {
         RenewEngineCore();
     });
 }
Beispiel #2
0
 private void RenewEngine()
 {
     _Pool.Do(() =>
     {
         DisposeEngine();
         _Engine = new DBreezeEngine(directory);
         _Tx     = _Engine.GetTransaction();
     });
 }
Beispiel #3
0
 private void RenewEngine()
 {
     _Pool.Do(() =>
     {
         DisposeEngine();
         int tried = 0;
         while (true)
         {
             try
             {
                 _Engine = new DBreezeEngine(directory);
                 break;
             }
             catch when(tried < 5)
             {
                 tried++;
                 Thread.Sleep(5000);
             }
         }
         _Tx = _Engine.GetTransaction();
     });
 }
Beispiel #4
0
 public void UpdateOrInsert <T>(string partitionKey, string rowKey, T data, Func <T, T, T> update)
 {
     _CustomThreadPool.Do(() =>
     {
         var engine = GetEngine(partitionKey);
         using (var tx = engine.GetTransaction())
         {
             T newValue      = data;
             var existingRow = tx.Select <string, byte[]>(GetTableName <T>(), rowKey);
             if (existingRow != null && existingRow.Exists)
             {
                 var existing = Serializer.ToObject <T>(Unzip(existingRow.Value));
                 if (existing != null)
                 {
                     newValue = update(existing, newValue);
                 }
             }
             tx.Insert(GetTableName <T>(), rowKey, Zip(Serializer.ToString(newValue)));
             tx.Commit();
         }
     });
 }