/// <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()); }
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)); }
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); }
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>()); }
public DbCache(DB db, DataEntryPrefix prefix) { this.db = db; this.prefix = prefix; }
private static string BuildKey(this DataEntryPrefix type, string key) { return(string.Format("{0}:{1}", key, type)); }
public static SliceBuilder Begin(DataEntryPrefix prefix) { return new SliceBuilder().Add((byte)prefix); }
public bool TryGetValue(DataEntryPrefix entry, byte[] key, out byte[] value) { throw new NotImplementedException(); }
public void SetValue(DataEntryPrefix entry, byte[] key, byte[] value) { throw new NotImplementedException(); }
public bool RemoveKey(DataEntryPrefix entry, byte[] key) { throw new NotImplementedException(); }
public IEnumerable <KeyValuePair <byte[], byte[]> > GetKeyValues(DataEntryPrefix entry, byte[] startKey) { throw new NotImplementedException(); }
public IEnumerable <byte[]> GetKeys(DataEntryPrefix entry, byte[] startKey) { throw new NotImplementedException(); }
/// <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")); }
public static SliceBuilder Begin(DataEntryPrefix prefix) { return(new SliceBuilder().Add((byte)prefix)); }
public static void Put(this WriteBatch batch, DataEntryPrefix prefix, ISerializable key, ISerializable value) { batch.Put(SliceBuilder.Begin(prefix).Add(key), value.ToArray()); }
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)))); }
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>()); }
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>())); }
/// <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())); }
public static void Delete(this WriteBatch batch, DataEntryPrefix prefix, ISerializable key) { batch.Delete(SliceBuilder.Begin(prefix).Add(key)); }
/// <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) }); }