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 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 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 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 RedisMultiBytes Sort(RedisParam key, bool descending, bool alpha = false, int start = -1, int end = -1, RedisParam?by = null, RedisParam?get = null) { if (key.IsNull) { throw new ArgumentNullException("key"); } ValidateNotDisposed(); var parameters = new RedisParam[] { key }; if (descending) { parameters = parameters.Join(RedisCommandList.Descending); } if (alpha) { parameters = parameters.Join(RedisCommandList.Alpha); } if (start > -1 && end > -1) { parameters = parameters .Join(RedisCommandList.Limit) .Join(start.ToBytes()) .Join(end.ToBytes()); } if (by.HasValue && !by.Value.IsEmpty) { parameters = parameters .Join(RedisCommandList.By) .Join(by); } if (get.HasValue && !get.Value.IsEmpty) { parameters = parameters .Join(RedisCommandList.Get) .Join(get); } return(ExpectMultiDataBytes(new RedisCommand(DbIndex, RedisCommandList.Sort, parameters))); }
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 RPush(RedisParam key, RedisParam[] values) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (values == null) { throw new ArgumentNullException("values"); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.RPush, key.Join(values)))); }
public RedisInteger SAdd(RedisParam key, RedisParam member, params RedisParam[] members) { ValidateNotDisposed(); ValidateKeyAndValue(key, member, valueName: "member"); if (members.Length > 0) { var parameters = key .Join(member) .Join(members); return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.SAdd, parameters))); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.SAdd, key, member))); }
public RedisScanBytes Scan(ulong cursor = 0uL, int count = 10, RedisParam?match = null) { ValidateNotDisposed(); var parameters = new RedisParam[] { 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.ToScanBytes(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.Scan, parameters)))); }
public RedisMultiString SUnionStrings(RedisParam key, params RedisParam[] keys) { if (key.IsNull) { throw new ArgumentNullException("key"); } ValidateNotDisposed(); if (keys.Length > 0) { var parameters = key.Join(keys); return(ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.SUnion, parameters))); } return(ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.SUnion, key))); }
public RedisInteger SUnionStore(RedisParam toKey, params RedisParam[] keys) { if (toKey.IsNull) { throw new ArgumentNullException("toKey"); } ValidateNotDisposed(); if (keys.Length > 0) { var parameters = toKey.Join(keys); return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.SUnionStore, parameters))); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.SUnionStore, toKey))); }
public RedisMultiBytes SDiff(RedisParam fromKey, params RedisParam[] keys) { if (fromKey.IsNull) { throw new ArgumentNullException("fromKey"); } ValidateNotDisposed(); if (keys.Length > 0) { var parameters = fromKey.Join(keys); return(ExpectMultiDataBytes(new RedisCommand(DbIndex, RedisCommandList.SDiff, parameters))); } return(ExpectMultiDataBytes(new RedisCommand(DbIndex, RedisCommandList.SDiff, fromKey))); }
public RedisInteger Del(RedisParam key, params RedisParam[] keys) { if (key.IsNull) { throw new ArgumentNullException("key"); } ValidateNotDisposed(); if (keys.Length > 0) { var parameters = key.Join(keys); return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.Del, parameters))); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.Del, keys))); }
public RedisBool PfAdd(RedisParam key, RedisParam element, params RedisParam[] elements) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (element.IsNull) { throw new ArgumentNullException("element"); } ValidateNotDisposed(); var length = elements.Length; if (length > 0) { var parameters = key.Join(element).Join(elements); return(ExpectOne(new RedisCommand(DbIndex, RedisCommandList.PfAdd, parameters))); } return(ExpectOne(new RedisCommand(DbIndex, RedisCommandList.PfAdd, key, element))); }
public RedisBool PfMerge(RedisParam destKey, RedisParam sourceKey, params RedisParam[] sourceKeys) { if (destKey.IsNull) { throw new ArgumentNullException("destKey"); } if (sourceKey.IsNull) { throw new ArgumentNullException("sourceKey"); } ValidateNotDisposed(); var length = sourceKeys.Length; if (length > 0) { var parameters = destKey.Join(sourceKey).Join(sourceKeys); return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.Quit, parameters))); } return(ExpectOK(new RedisCommand(DbIndex, RedisCommandList.Quit, destKey, sourceKey))); }
public RedisMultiString HMGetStrings(RedisParam key, RedisParam field, params RedisParam[] fields) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (field.IsEmpty) { throw new ArgumentNullException("field"); } ValidateNotDisposed(); if (fields.Length > 0) { var parameters = key .Join(field) .Join(fields); return(ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.HMGet, parameters))); } return(ExpectMultiDataStrings(new RedisCommand(DbIndex, RedisCommandList.HMGet, key, field.ToBytes()))); }
public RedisInteger HDel(RedisParam key, RedisParam field, params RedisParam[] fields) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (field.IsEmpty) { throw new ArgumentNullException("field"); } ValidateNotDisposed(); if (fields.Length > 0) { var parameters = key .Join(field) .Join(fields); return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.HDel, parameters))); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.HDel, key, field))); }
public RedisResult <RedisGeoPosition[]> GeoPosition(RedisParam key, RedisParam member, params RedisParam[] members) { if (key.IsEmpty) { throw new ArgumentNullException("key"); } if (member.IsEmpty) { throw new ArgumentNullException("member"); } var parameters = key.Join(member); foreach (var m in members) { if (!m.IsEmpty) { parameters = parameters.Join(m); } } return(RedisCommandUtils.ToGeoPosition(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.GeoPos, parameters)))); }
public RedisInteger SRem(RedisParam key, RedisParam member, params RedisParam[] members) { if (key.IsNull) { throw new ArgumentNullException("key"); } if (member.IsNull) { throw new ArgumentNullException("member"); } ValidateNotDisposed(); if (members.Length > 0) { var parameters = key .Join(member) .Join(members); return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.SRem, parameters))); } return(ExpectInteger(new RedisCommand(DbIndex, RedisCommandList.SRem, key, member))); }