コード例 #1
0
        /// <summary>
        /// Builds the concatenated key based on data type and desired key
        /// </summary>
        /// <param name="type">Data type</param>
        /// <param name="key">Desired key</param>
        /// <returns>Resulting key</returns>
        private byte[] BuildKey(DataEntryPrefix type, byte[] key)
        {
            List <byte> bytes = new List <byte>(key);

            bytes.Insert(0, (byte)type);
            return(bytes.ToArray());
        }
コード例 #2
0
ファイル: Helper.cs プロジェクト: PlumpMath/Pure
        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));
        }
コード例 #3
0
        private static byte[] BuildKey(this DataEntryPrefix dataEntryPrefix, byte[] key)
        {
            var len   = key.Length;
            var bytes = new byte[len + 1];

            bytes[0] = (byte)dataEntryPrefix;
            Array.Copy(key, 0, bytes, 1, len);

            return(bytes);
        }
コード例 #4
0
ファイル: Helper.cs プロジェクト: PlumpMath/Pure
        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>());
        }
コード例 #5
0
 public DbCache(DB db, DataEntryPrefix prefix)
 {
     this.db     = db;
     this.prefix = prefix;
 }
コード例 #6
0
 private static string BuildKey(this DataEntryPrefix type, string key)
 {
     return(string.Format("{0}:{1}", key, type));
 }
コード例 #7
0
ファイル: SliceBuilder.cs プロジェクト: erikzhang/IceWallet
 public static SliceBuilder Begin(DataEntryPrefix prefix)
 {
     return new SliceBuilder().Add((byte)prefix);
 }
コード例 #8
0
 public bool TryGetValue(DataEntryPrefix entry, byte[] key, out byte[] value)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
 public void SetValue(DataEntryPrefix entry, byte[] key, byte[] value)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
 public bool RemoveKey(DataEntryPrefix entry, byte[] key)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
 public IEnumerable <KeyValuePair <byte[], byte[]> > GetKeyValues(DataEntryPrefix entry, byte[] startKey)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
 public IEnumerable <byte[]> GetKeys(DataEntryPrefix entry, byte[] startKey)
 {
     throw new NotImplementedException();
 }
コード例 #13
0
 /// <summary>
 /// Gets the values from a hash set at key.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public RedisValue Get(DataEntryPrefix type, string key)
 {
     return(_redisDb.HashGet(BuildKey(type, key), "data"));
 }
コード例 #14
0
ファイル: SliceBuilder.cs プロジェクト: wuqionglei/IceWallet
 public static SliceBuilder Begin(DataEntryPrefix prefix)
 {
     return(new SliceBuilder().Add((byte)prefix));
 }
コード例 #15
0
ファイル: Helper.cs プロジェクト: PlumpMath/Pure
 public static void Put(this WriteBatch batch, DataEntryPrefix prefix, ISerializable key, ISerializable value)
 {
     batch.Put(SliceBuilder.Begin(prefix).Add(key), value.ToArray());
 }
コード例 #16
0
ファイル: Helper.cs プロジェクト: PlumpMath/Pure
 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))));
 }
コード例 #17
0
ファイル: Helper.cs プロジェクト: PlumpMath/Pure
 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>());
 }
コード例 #18
0
ファイル: Helper.cs プロジェクト: PlumpMath/Pure
 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>()));
 }
コード例 #19
0
 /// <summary>
 /// Builds the concatenated key based on data type and desired key
 /// </summary>
 /// <param name="type">Data type</param>
 /// <param name="key">Desired key</param>
 /// <returns></returns>
 private string BuildKey(DataEntryPrefix type, string key)
 {
     return(string.Format("{0}:{1}", key, type.ToString()));
 }
コード例 #20
0
ファイル: Helper.cs プロジェクト: PlumpMath/Pure
 public static void Delete(this WriteBatch batch, DataEntryPrefix prefix, ISerializable key)
 {
     batch.Delete(SliceBuilder.Begin(prefix).Add(key));
 }
コード例 #21
0
 /// <summary>
 /// Sets the values in a hash set at key.  Using a Redis HashSet will give us O(1) complexity on search
 /// </summary>
 /// <param name="type">The data entry type</param>
 /// <param name="key">The key to use</param>
 /// <param name="value">The value to be written as the hash entry</param>
 public void Set(DataEntryPrefix type, string key, RedisValue value)
 {
     _redisDb.HashSet(BuildKey(type, key), new HashEntry[] { new HashEntry("data", value) });
 }