public double HIncrByFloat(string key, string field, double incrementBy) { if (!this.IsValidField(field)) { return(0.0); } RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0.0 : client.HIncrbyFloat(key, UTF8String.ToBytes(field), incrementBy)); }
public string GetValueFromHash(string hashId, string key) { if (!this.IsValidField(key)) { return(null); } RedisNativeClient client = this.pool.GetRedisClient(hashId); return((client == null) ? null : UTF8String.ToString(client.HGet(hashId, UTF8String.ToBytes(key)))); }
public long HIncrBy(string key, string field, int incrementBy) { if (!this.IsValidField(field)) { return(0L); } RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0L : client.HIncrby(key, UTF8String.ToBytes(field), incrementBy)); }
public bool SetValueIfNotExists(string key, string value, int expirySeconds) { if (!this.IsValidValue(value)) { return(false); } RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? false : client.Set(key, UTF8String.ToBytes(value), exists: false, expirySeconds: expirySeconds)); }
public long HExists(string key, string field) { if (!this.IsValidField(field)) { return(0L); } RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0L : client.HExists(key, UTF8String.ToBytes(field))); }
public static byte[][] ToBytesArray(List <string> s) { var bytes = new byte[s.Count][]; for (var i = 0; i < s.Count; ++i) { var item = s[i]; bytes[i] = (item != null) ? UTF8String.ToBytes(item) : new byte[0]; } return(bytes); }
public static byte[][] ToBytesArray(string[] s) { var bytes = new byte[s.Length][]; for (var i = 0; i < s.Length; i++) { var item = s[i]; bytes[i] = (item != null) ? UTF8String.ToBytes(item) : new byte[0]; } return(bytes); }
public bool LSet(string key, int index, string value) { RedisNativeClient client = this.pool.GetRedisClient(key); if (client == null) { return(false); } client.LSet(key, index, UTF8String.ToBytes(value)); return(true); }
public long Append(string key, string value) { if (!this.IsValidValue(value)) { return(0L); } // Get the corresponding Redis client. RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0L : client.Append(key, UTF8String.ToBytes(value))); }
//------------------------------------------------------------------ // STRING public bool Set(string key, string value) { if (!this.IsValidValue(value)) { return(false); } // Get the corresponding Redis client. RedisNativeClient client = this.pool.GetRedisClient(key); if (client == null) { return(false); } client.Set(key, UTF8String.ToBytes(value)); return(true); }
public bool HMSet(string key, IEnumerable <KeyValuePair <string, string> > keyValuePairs) { int len = 0; foreach (KeyValuePair <string, string> node in keyValuePairs) { if (!this.IsValidField(node.Key) || !this.IsValidValue(node.Value)) { return(false); } len++; } if (len == 0) { return(false); } RedisNativeClient client = this.pool.GetRedisClient(key); if (client == null) { return(false); } var keys = new byte[len][]; var values = new byte[len][]; int i = 0; foreach (KeyValuePair <string, string> node in keyValuePairs) { keys[i] = UTF8String.ToBytes(node.Key); values[i] = UTF8String.ToBytes(node.Value); } client.HMSet(key, keys, values); return(true); }
public long HSetNx(string key, string field, string value) { RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0L : client.HSetNX(key, UTF8String.ToBytes(field), UTF8String.ToBytes(value))); }
public long RPushX(string key, string value) { RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0L : client.RPushX(key, UTF8String.ToBytes(value))); }
public long LRem(string key, int removeNoOfMatches, string value) { RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0L : client.LRem(key, removeNoOfMatches, UTF8String.ToBytes(value))); }
public long PrependItemToList(string listId, string value) { RedisNativeClient client = this.pool.GetRedisClient(listId); return((client == null) ? 0L : client.LPush(listId, UTF8String.ToBytes(value))); }