Esempio n. 1
0
        public static T TryGet <T>(this DB db, ReadOptions options, DataEntryPrefix prefix, ISerializable key) where T : class, ISerializable, new()
        {
            Slice slice;

            if (!db.TryGet(options, SliceBuilder.Begin(prefix).Add(key), out slice))
            {
                return(null);
            }
            return(slice.ToArray().AsSerializable <T>());
        }
Esempio n. 2
0
        public static T TryGet <T>(this DB db, ReadOptions options, DataEntryPrefix prefix, ISerializable key, Func <Slice, T> resultSelector) where T : class
        {
            Slice slice;

            if (!db.TryGet(options, SliceBuilder.Begin(prefix).Add(key), out slice))
            {
                return(null);
            }
            return(resultSelector(slice));
        }
Esempio n. 3
0
 public static SliceBuilder Begin(DataEntryPrefix prefix)
 {
     return(new SliceBuilder().Add((byte)prefix));
 }
Esempio n. 4
0
 public static void Delete(this WriteBatch batch, DataEntryPrefix prefix, ISerializable key)
 {
     batch.Delete(SliceBuilder.Begin(prefix).Add(key));
 }
Esempio n. 5
0
 public static void Put(this WriteBatch batch, DataEntryPrefix prefix, ISerializable key, ISerializable value)
 {
     batch.Put(SliceBuilder.Begin(prefix).Add(key), value.ToArray());
 }
Esempio n. 6
0
 public static T Get <T>(this DB db, ReadOptions options, DataEntryPrefix prefix, ISerializable key, Func <Slice, T> resultSelector)
 {
     return(resultSelector(db.Get(options, SliceBuilder.Begin(prefix).Add(key))));
 }
Esempio n. 7
0
 public static T Get <T>(this DB db, ReadOptions options, DataEntryPrefix prefix, ISerializable key) where T : class, ISerializable, new()
 {
     return(db.Get(options, SliceBuilder.Begin(prefix).Add(key)).ToArray().AsSerializable <T>());
 }
Esempio n. 8
0
 public static IEnumerable <T> Find <T>(this DB db, ReadOptions options, DataEntryPrefix prefix) where T : class, ISerializable, new()
 {
     return(Find(db, options, SliceBuilder.Begin(prefix), (k, v) => v.ToArray().AsSerializable <T>()));
 }
Esempio n. 9
0
 public DbCache(DB db, DataEntryPrefix prefix)
 {
     this.db     = db;
     this.prefix = prefix;
 }