Ejemplo n.º 1
0
 /// <summary>
 /// 查询某个Key
 /// </summary>
 /// <typeparam name="T">值泛型</typeparam>
 /// <param name="db">待查询db</param>
 /// <param name="options">读选项</param>
 /// <param name="prefix">待查询前缀</param>
 /// <param name="key">待查询Key</param>
 /// <param name="resultSelector">值处理回调函数</param>
 /// <returns>T</returns>
 public static T Get <T>(this DB db, ReadOptions options, byte prefix, ISerializable key, Func <Slice, T> resultSelector)
 {
     return(resultSelector(db.Get(options, SliceBuilder.Begin(prefix).Add(key))));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 查询前缀匹配的元素
 /// </summary>
 /// <typeparam name="T">值泛型</typeparam>
 /// <param name="db">待查询db</param>
 /// <param name="options">读选项</param>
 /// <param name="prefix">待查询前缀</param>
 /// <returns>T列表</returns>
 public static IEnumerable <T> Find <T>(this DB db, ReadOptions options, byte prefix) where T : class, ISerializable, new()
 {
     return(Find(db, options, SliceBuilder.Begin(prefix), (k, v) => v.ToArray().AsSerializable <T>()));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 查询某个Key
 /// </summary>
 /// <typeparam name="T">值泛型</typeparam>
 /// <param name="db">待查询db</param>
 /// <param name="options">读选项</param>
 /// <param name="prefix">待查询前缀</param>
 /// <param name="key">待查询Key</param>
 /// <returns>T</returns>
 public static T Get <T>(this DB db, ReadOptions options, byte prefix, ISerializable key) where T : class, ISerializable, new()
 {
     return(db.Get(options, SliceBuilder.Begin(prefix).Add(key)).ToArray().AsSerializable <T>());
 }
Ejemplo n.º 4
0
 public Iterator NewIterator(ReadOptions options)
 {
     return(new Iterator(Native.leveldb_create_iterator(handle, options.handle)));
 }