Exemplo n.º 1
0
 public void Put(TKey key, T data)
 {
     _env.WithAutogrowth(() =>
     {
         using (var tx = BeginTransaction())
         {
             tx.Put(key, data);
             tx.Commit();
         }
     });
 }
Exemplo n.º 2
0
 public long Append(params byte[][] values)
 {
     return(_env.WithAutogrowth(() =>
     {
         using (var tx = _env.BeginTransaction())
         {
             var nextKey = 0L;
             using (var c = tx.CreateCursor(_db))
             {
                 if (c.MoveToLast())
                 {
                     nextKey = BitConverter.ToInt64(c.Current.Key, 0) + 1L;
                 }
             }
             foreach (var value in values)
             {
                 tx.Put(_db, BitConverter.GetBytes(nextKey), value, PutOptions.AppendData | PutOptions.NoOverwrite);
                 nextKey++;
             }
             tx.Commit();
             return nextKey - 1L;
         }
     }));
 }
 public static void WithAutogrowth(this LightningEnvironment env, Action action)
 => env.WithAutogrowth <bool>(() => { action(); return(true); });