public RedisBool HMSet(RedisParam key, Hashtable values) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (values.IsEmpty()) { throw new ArgumentNullException("values"); } ValidateNotDisposed(); var parameters = new RedisParam[1 + (2 * values.Count)]; parameters[0] = key; var i = 1; foreach (DictionaryEntry de in values) { parameters[i++] = de.Key.ToBytes(); parameters[i++] = de.Value.ToBytes(); } return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.HMSet, parameters))); }
public RedisBool HMSet(RedisParam key, IDictionary <RedisParam, RedisParam> values) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (values == null || values.Count == 0) { throw new ArgumentNullException("values"); } ValidateNotDisposed(); var parameters = new RedisParam[1 + (2 * values.Count)]; parameters[0] = key; var i = 1; foreach (var kvp in values) { parameters[i++] = kvp.Key; parameters[i++] = kvp.Value; } return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.HMSet, parameters))); }
public RedisBool HMSet(RedisParam key, RedisParam field, RedisParam value, RedisParam[] fields = null, RedisParam[] values = null) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (field.IsEmpty) { throw new ArgumentNullException("field"); } ValidateNotDisposed(); if (value.Length > RedisConstants.MaxValueLength) { throw new ArgumentException("value is limited to 1GB", "value"); } if (fields.Length > 0) { if (values == null || values.Length != fields.Length) { throw new ArgumentException("Field and values length does not match", "field"); } var parameters = key .Join(field) .Join(value) .Join(fields.Merge(values)); return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.HMSet, parameters))); } return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.HMSet, key, field, value))); }
public RedisInteger GeoAdd(RedisParam key, RedisGeospatialItem member, params RedisGeospatialItem[] members) { if (key.IsEmpty) { throw new ArgumentNullException("key"); } if (member.IsEmpty) { throw new ArgumentNullException("member"); } if (members.IsEmpty()) { return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.GeoAdd, key, member.Longitude.ToBytes(), member.Latitude.ToBytes(), member.Name.ToBytes()))); } var parameters = key .Join(member.Longitude.ToBytes()) .Join(member.Latitude.ToBytes()) .Join(member.Name.ToBytes()); foreach (var m in members) { parameters = parameters .Join(m.Longitude.ToBytes()) .Join(m.Latitude.ToBytes()) .Join(m.Name.ToBytes()); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.GeoAdd, parameters))); }
public RedisResult <IDictionary <string, string> > ConfigGet(RedisParam parameter) { if (parameter.IsNull) { throw new ArgumentNullException("parameter"); } var lines = ExpectMultiDataStrings(new RedisCommand(RedisConstants.UninitializedDbIndex, RedisCommandList.Config, RedisCommandList.Get, parameter.ToBytes())); if (!ReferenceEquals(lines, null)) { var value = lines.Value; if (value != null) { var linesLength = value.Length; if (linesLength > 0) { var result = new Dictionary <string, string>(linesLength / 2); for (var i = 0; i < linesLength; i += 2) { var key = (value[i] ?? String.Empty).Trim(); if (!key.IsEmpty()) { result[key] = (value[i + 1] ?? String.Empty).Trim(); } } return(new RedisResult <IDictionary <string, string> >(result)); } } } return(new RedisResult <IDictionary <string, string> >(null)); }
public RedisBool Restore(RedisParam key, long ttl, RedisParam value) { ValidateNotDisposed(); ValidateKeyAndValue(key, value); return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.Rename, key, ttl.ToBytes(), value))); }
public RedisMultiBytes GeoHash(RedisParam key, RedisParam member, params RedisParam[] members) { if (key.IsEmpty) { throw new ArgumentNullException("key"); } if (member.IsEmpty) { throw new ArgumentNullException("member"); } if (members.IsEmpty()) { return(ExpectMultiDataBytes(new RedisCommand(DbIndex, RedisCommandList.GeoHash, key, member))); } var parameters = key.Join(member); foreach (var m in members) { if (!m.IsEmpty) { parameters = parameters.Join(m); } } return(ExpectMultiDataBytes(new RedisCommand(DbIndex, RedisCommandList.GeoHash, parameters))); }
public RedisScanStrings SScanString(RedisParam key, ulong cursor = 0uL, int count = 10, RedisParam?match = null) { if (key.IsNull) { throw new ArgumentNullException("key"); } ValidateNotDisposed(); var parameters = new RedisParam[] { key, cursor.ToBytes() }; if (match.HasValue) { var value = match.Value; if (!value.IsEmpty) { parameters = parameters.Join(RedisCommandList.Match); parameters = parameters.Join(value); } } if (count > 0) { parameters = parameters.Join(RedisCommandList.Count); parameters = parameters.Join(count.ToBytes()); } return(RedisCommandUtils.ToScanStrings(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.SScan, parameters)))); }
public bool Watch(RedisParam key, params RedisParam[] keys) { ValidateNotDisposed(); if (m_State == (int)RedisBatchState.Executing) { throw new RedisException("Transaction is being executed", RedisErrorCode.ExecutionError); } var queue = m_WatchQ; if (queue == null) { queue = (m_WatchQ = new RedisSynchronizedQueue <RedisParam>()); } if (!key.IsEmpty) { queue.Enqueue(key); } var length = keys.Length; if (length > 0) { foreach (var k in keys) { if (!k.IsEmpty) { queue.Enqueue(k); } } } return(true); }
public RedisResult <Hashtable> HGetAllHashtable(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } var result = ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.HGetAll, key)); if (!ReferenceEquals(result, null)) { var value = result.Value; if (value != null) { var length = value.Length; if (length == 0) { return(new RedisResult <Hashtable>(new Hashtable())); } var h = new Hashtable(length / 2); for (var i = 0; i < length; i += 2) { h[value[i]] = value[i + 1]; } return(new RedisResult <Hashtable>(h)); } } return(new RedisResult <Hashtable>(null)); }
public RedisBool LInsert(RedisParam key, bool insertBefore, RedisParam pivot, RedisParam value) { ValidateKeyAndValue(key, value); var prePost = insertBefore ? RedisCommandList.Before : RedisCommandList.After; return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.LInsert, key, prePost, pivot, value))); }
public RedisString Ping(RedisParam msg) { if (msg.IsEmpty) { return(ExpectSimpleString(new RedisCommand(RedisConstants.UninitializedDbIndex, RedisCommandList.Ping))); } return(ExpectBulkString(new RedisCommand(RedisConstants.UninitializedDbIndex, RedisCommandList.Ping, msg))); }
public RedisMultiString Keys(RedisParam pattern) { if (pattern.IsNull) { throw new ArgumentNullException("pattern"); } return(ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.Keys, pattern))); }
public RedisBool ExpireAt(RedisParam key, int timestamp) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectGreaterThanZero(new RedisCommand(DbIndex, RedisCommandList.ExpireAt, key, timestamp.ToBytes()))); }
public RedisBool Expire(RedisParam key, int seconds) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectGreaterThanZero(new RedisCommand(DbIndex, RedisCommandList.Expire, key, seconds.ToBytes()))); }
public RedisBool Exists(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectGreaterThanZero(new RedisCommand(DbIndex, RedisCommandList.Exists, key))); }
public RedisBytes Dump(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectBulkStringBytes(new RedisCommand(DbIndex, RedisCommandList.Dump, key))); }
public RedisString Type(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectSimpleString(new RedisCommand(DbIndex, RedisCommandList.Type, key))); }
public RedisMultiString SMemberStrings(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.SMembers, key))); }
public RedisBool Auth(RedisParam password) { if (password.IsEmpty) { throw new ArgumentNullException("password"); } return(ExpectOK(new RedisCommand(RedisConstants.UninitializedDbIndex, RedisCommandList.Auth, password))); }
public RedisString ObjectEncodingString(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectBulkString(new RedisCommand(DbIndex, RedisCommandList.Object, RedisCommandList.Encoding, key))); }
public RedisBool Move(RedisParam key, int db) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectGreaterThanZero(new RedisCommand(DbIndex, RedisCommandList.Move, key, db.ToBytes()))); }
public RedisString SRandMemberString(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectBulkString(new RedisCommand(DbIndex, RedisCommandList.SRandMember, key))); }
public RedisMultiString SRandMemberString(RedisParam key, int count) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.SRandMember, key, count.ToBytes()))); }
public RedisString Echo(RedisParam msg) { if (msg.IsNull) { throw new ArgumentNullException("msg"); } return(ExpectBulkString(new RedisCommand(RedisConstants.UninitializedDbIndex, RedisCommandList.Echo, msg))); }
public RedisResult <RedisGeoRadiusResult[]> GeoRadius(RedisParam key, RedisGeoPosition position, double radius, RedisGeoDistanceUnit unit, bool withCoord = false, bool withDist = false, bool withHash = false, int count = -1, RedisSortDirection sort = RedisSortDirection.Default, RedisParam?storeKey = null, RedisParam?storeDistanceKey = null) { if (key.IsEmpty) { throw new ArgumentNullException("key"); } var parameters = key .Join(position.Longitude.ToBytes()) .Join(position.Latitude.ToBytes()) .Join(radius.ToBytes()) .Join(ToBytes(unit)); if (withCoord) { parameters = parameters.Join(RedisCommandList.WithCoord); } if (withDist) { parameters = parameters.Join(RedisCommandList.WithDist); } if (withHash) { parameters = parameters.Join(RedisCommandList.WithHash); } if (count > -1) { parameters = parameters.Join(RedisCommandList.Count).Join(count.ToBytes()); } if (sort == RedisSortDirection.Ascending) { parameters = parameters.Join(RedisCommandList.Ascending); } else if (sort == RedisSortDirection.Descending) { parameters = parameters.Join(RedisCommandList.Descending); } if (storeKey.HasValue && !storeKey.Value.IsEmpty) { parameters = parameters.Join(RedisCommandList.Store).Join(storeKey.ToBytes()); } if (storeDistanceKey.HasValue && !storeDistanceKey.Value.IsEmpty) { parameters = parameters.Join(RedisCommandList.StoreDist).Join(storeDistanceKey.ToBytes()); } return(RedisCommandUtils.ToGeoRadiusArray(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.GeoRadius, parameters)))); }
public RedisInteger DecrBy(RedisParam key, long count) { if (key.IsEmpty) { throw new ArgumentNullException("key"); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.DecrBy, key, count.ToBytes()))); }
public RedisBool SIsMember(RedisParam key, RedisParam member) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectGreaterThanZero(new RedisCommand(DbIndex, RedisCommandList.SIsMember, key, member))); }
public RedisInteger ObjectIdleTime(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.Object, RedisCommandList.IdleTime, key))); }
public RedisInteger Ttl(RedisParam key) { if (key.IsNull) { throw new ArgumentNullException("key"); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.Ttl, key))); }