diff --git a/lib/ServiceStack.Common.dll b/lib/ServiceStack.Common.dll index d28e55e7..669a2af2 100755 Binary files a/lib/ServiceStack.Common.dll and b/lib/ServiceStack.Common.dll differ diff --git a/lib/ServiceStack.Interfaces.dll b/lib/ServiceStack.Interfaces.dll index 63b006f1..d93c2b70 100755 Binary files a/lib/ServiceStack.Interfaces.dll and b/lib/ServiceStack.Interfaces.dll differ diff --git a/lib/ServiceStack.Text.dll b/lib/ServiceStack.Text.dll index 339722f1..5679f340 100755 Binary files a/lib/ServiceStack.Text.dll and b/lib/ServiceStack.Text.dll differ diff --git a/src/ServiceStack.Redis/BasicRedisClientManager.cs b/src/ServiceStack.Redis/BasicRedisClientManager.cs index e528a6d1..d6d03a08 100644 --- a/src/ServiceStack.Redis/BasicRedisClientManager.cs +++ b/src/ServiceStack.Redis/BasicRedisClientManager.cs @@ -36,7 +36,7 @@ public partial class BasicRedisClientManager public IRedisClientFactory RedisClientFactory { get; set; } - public int Db { get; private set; } + public long Db { get; private set; } public Action ConnectionFilter { get; set; } diff --git a/src/ServiceStack.Redis/Generic/ManagedListGeneric.cs b/src/ServiceStack.Redis/Generic/ManagedListGeneric.cs index 9c6f50d1..f2ca6997 100644 --- a/src/ServiceStack.Redis/Generic/ManagedListGeneric.cs +++ b/src/ServiceStack.Redis/Generic/ManagedListGeneric.cs @@ -30,7 +30,7 @@ private List GetRedisList() return client.Lists[key].ToList(); } } - public int IndexOf(T item) + public int IndexOf(T item) { return GetRedisList().IndexOf(item); } @@ -93,7 +93,7 @@ public void CopyTo(T[] array, int arrayIndex) GetRedisList().CopyTo(array, arrayIndex); } - public int Count + public int Count { get { return GetRedisList().Count(); } } diff --git a/src/ServiceStack.Redis/Generic/RedisClientHash.Generic.cs b/src/ServiceStack.Redis/Generic/RedisClientHash.Generic.cs index a8c1d560..dc29f434 100644 --- a/src/ServiceStack.Redis/Generic/RedisClientHash.Generic.cs +++ b/src/ServiceStack.Redis/Generic/RedisClientHash.Generic.cs @@ -86,7 +86,7 @@ public bool Remove(KeyValuePair item) public int Count { - get { return client.GetHashCount(this); } + get { return (int)client.GetHashCount(this); } } public bool IsReadOnly diff --git a/src/ServiceStack.Redis/Generic/RedisClientList.Generic.cs b/src/ServiceStack.Redis/Generic/RedisClientList.Generic.cs index 208470f7..3978c4f8 100644 --- a/src/ServiceStack.Redis/Generic/RedisClientList.Generic.cs +++ b/src/ServiceStack.Redis/Generic/RedisClientList.Generic.cs @@ -103,7 +103,7 @@ public int Count { get { - return client.GetListCount(this); + return (int)client.GetListCount(this); } } @@ -167,12 +167,12 @@ public void Trim(int keepStartingFrom, int keepEndingAt) client.TrimList(this, keepStartingFrom, keepEndingAt); } - public int RemoveValue(T value) + public long RemoveValue(T value) { return client.RemoveItemFromList(this, value); } - public int RemoveValue(T value, int noOfMatches) + public long RemoveValue(T value, int noOfMatches) { return client.RemoveItemFromList(this, value, noOfMatches); } diff --git a/src/ServiceStack.Redis/Generic/RedisClientSet.Generic.cs b/src/ServiceStack.Redis/Generic/RedisClientSet.Generic.cs index b593a4ce..7f091e8a 100644 --- a/src/ServiceStack.Redis/Generic/RedisClientSet.Generic.cs +++ b/src/ServiceStack.Redis/Generic/RedisClientSet.Generic.cs @@ -95,7 +95,7 @@ public int Count { get { - var setCount = client.GetSetCount(this); + var setCount = (int)client.GetSetCount(this); return setCount; } } diff --git a/src/ServiceStack.Redis/Generic/RedisClientSortedSet.Generic.cs b/src/ServiceStack.Redis/Generic/RedisClientSortedSet.Generic.cs index 14733858..668ac64a 100644 --- a/src/ServiceStack.Redis/Generic/RedisClientSortedSet.Generic.cs +++ b/src/ServiceStack.Redis/Generic/RedisClientSortedSet.Generic.cs @@ -100,7 +100,7 @@ public int Count { get { - var setCount = client.GetSortedSetCount(this); + var setCount = (int)client.GetSortedSetCount(this); return setCount; } } @@ -124,10 +124,10 @@ public double IncrementItem(T item, double incrementBy) public int IndexOf(T item) { - return client.GetItemIndexInSortedSet(this, item); + return (int)client.GetItemIndexInSortedSet(this, item); } - public int IndexOfDescending(T item) + public long IndexOfDescending(T item) { return client.GetItemIndexInSortedSetDesc(this, item); } @@ -167,12 +167,12 @@ public List GetRangeByHighestScore(double fromScore, double toScore, int? ski return client.GetRangeFromSortedSetByHighestScore(this, fromScore, toScore, skip, take); } - public int RemoveRange(int minRank, int maxRank) + public long RemoveRange(int minRank, int maxRank) { return client.RemoveRangeFromSortedSet(this, minRank, maxRank); } - public int RemoveRangeByScore(double fromScore, double toScore) + public long RemoveRangeByScore(double fromScore, double toScore) { return client.RemoveRangeFromSortedSetByScore(this, fromScore, toScore); } @@ -182,12 +182,12 @@ public double GetItemScore(T item) return client.GetItemScoreInSortedSet(this, item); } - public int PopulateWithIntersectOf(params IRedisSortedSet[] setIds) + public long PopulateWithIntersectOf(params IRedisSortedSet[] setIds) { return client.StoreIntersectFromSortedSets(this, setIds); } - public int PopulateWithUnionOf(params IRedisSortedSet[] setIds) + public long PopulateWithUnionOf(params IRedisSortedSet[] setIds) { return client.StoreUnionFromSortedSets(this, setIds); } diff --git a/src/ServiceStack.Redis/Generic/RedisTypedClient_App.cs b/src/ServiceStack.Redis/Generic/RedisTypedClient_App.cs index ee319379..4789ec14 100644 --- a/src/ServiceStack.Redis/Generic/RedisTypedClient_App.cs +++ b/src/ServiceStack.Redis/Generic/RedisTypedClient_App.cs @@ -57,7 +57,7 @@ public List GetRelatedEntities(object parentId) } } - public int GetRelatedEntitiesCount(object parentId) + public long GetRelatedEntitiesCount(object parentId) { var childRefKey = GetChildReferenceSetKey(parentId); return client.GetSetCount(childRefKey); diff --git a/src/ServiceStack.Redis/Generic/RedisTypedClient_Hash.cs b/src/ServiceStack.Redis/Generic/RedisTypedClient_Hash.cs index cfbbd3f3..180920ad 100644 --- a/src/ServiceStack.Redis/Generic/RedisTypedClient_Hash.cs +++ b/src/ServiceStack.Redis/Generic/RedisTypedClient_Hash.cs @@ -58,7 +58,7 @@ public bool RemoveEntryFromHash(IRedisHash hash, TKey key) return client.RemoveEntryFromHash(hash.Id, key.SerializeToString()); } - public int GetHashCount(IRedisHash hash) + public long GetHashCount(IRedisHash hash) { return client.GetHashCount(hash.Id); } diff --git a/src/ServiceStack.Redis/Generic/RedisTypedClient_List.cs b/src/ServiceStack.Redis/Generic/RedisTypedClient_List.cs index dfb1d3f5..d7351996 100644 --- a/src/ServiceStack.Redis/Generic/RedisTypedClient_List.cs +++ b/src/ServiceStack.Redis/Generic/RedisTypedClient_List.cs @@ -127,18 +127,18 @@ public void TrimList(IRedisList fromList, int keepStartingFrom, int keepEndin client.LTrim(fromList.Id, keepStartingFrom, keepEndingAt); } - public int RemoveItemFromList(IRedisList fromList, T value) + public long RemoveItemFromList(IRedisList fromList, T value) { const int removeAll = 0; return client.LRem(fromList.Id, removeAll, SerializeValue(value)); } - public int RemoveItemFromList(IRedisList fromList, T value, int noOfMatches) + public long RemoveItemFromList(IRedisList fromList, T value, int noOfMatches) { return client.LRem(fromList.Id, noOfMatches, SerializeValue(value)); } - public int GetListCount(IRedisList fromList) + public long GetListCount(IRedisList fromList) { return client.LLen(fromList.Id); } diff --git a/src/ServiceStack.Redis/Generic/RedisTypedClient_Set.cs b/src/ServiceStack.Redis/Generic/RedisTypedClient_Set.cs index ce61a136..e3c6d575 100644 --- a/src/ServiceStack.Redis/Generic/RedisTypedClient_Set.cs +++ b/src/ServiceStack.Redis/Generic/RedisTypedClient_Set.cs @@ -21,7 +21,7 @@ public partial class RedisTypedClient { public IHasNamed> Sets { get; set; } - public int Db + public long Db { get { return client.Db; } set { client.Db = value; } @@ -95,7 +95,7 @@ public void MoveBetweenSets(IRedisSet fromSet, IRedisSet toSet, T item) client.SMove(fromSet.Id, toSet.Id, SerializeValue(item)); } - public int GetSetCount(IRedisSet set) + public long GetSetCount(IRedisSet set) { return client.SCard(set.Id); } diff --git a/src/ServiceStack.Redis/Generic/RedisTypedClient_SortedSet.cs b/src/ServiceStack.Redis/Generic/RedisTypedClient_SortedSet.cs index 70257419..0e0f80ce 100644 --- a/src/ServiceStack.Redis/Generic/RedisTypedClient_SortedSet.cs +++ b/src/ServiceStack.Redis/Generic/RedisTypedClient_SortedSet.cs @@ -102,12 +102,12 @@ public double IncrementItemInSortedSet(IRedisSortedSet set, T value, double i return client.IncrementItemInSortedSet(set.Id, value.SerializeToString(), incrementBy); } - public int GetItemIndexInSortedSet(IRedisSortedSet set, T value) + public long GetItemIndexInSortedSet(IRedisSortedSet set, T value) { return client.GetItemIndexInSortedSet(set.Id, value.SerializeToString()); } - public int GetItemIndexInSortedSetDesc(IRedisSortedSet set, T value) + public long GetItemIndexInSortedSetDesc(IRedisSortedSet set, T value) { return client.GetItemIndexInSortedSetDesc(set.Id, value.SerializeToString()); } @@ -250,17 +250,17 @@ public List GetRangeFromSortedSetByHighestScore(IRedisSortedSet set, doubl return CreateGenericMap(map); } - public int RemoveRangeFromSortedSet(IRedisSortedSet set, int minRank, int maxRank) + public long RemoveRangeFromSortedSet(IRedisSortedSet set, int minRank, int maxRank) { return client.RemoveRangeFromSortedSet(set.Id, minRank, maxRank); } - public int RemoveRangeFromSortedSetByScore(IRedisSortedSet set, double fromScore, double toScore) + public long RemoveRangeFromSortedSetByScore(IRedisSortedSet set, double fromScore, double toScore) { return client.RemoveRangeFromSortedSetByScore(set.Id, fromScore, toScore); } - - public int GetSortedSetCount(IRedisSortedSet set) + + public long GetSortedSetCount(IRedisSortedSet set) { return client.GetSortedSetCount(set.Id); } @@ -270,12 +270,12 @@ public double GetItemScoreInSortedSet(IRedisSortedSet set, T value) return client.GetItemScoreInSortedSet(set.Id, value.SerializeToString()); } - public int StoreIntersectFromSortedSets(IRedisSortedSet intoSetId, params IRedisSortedSet[] setIds) + public long StoreIntersectFromSortedSets(IRedisSortedSet intoSetId, params IRedisSortedSet[] setIds) { return client.StoreIntersectFromSortedSets(intoSetId.Id, setIds.ConvertAll(x => x.Id).ToArray()); } - public int StoreUnionFromSortedSets(IRedisSortedSet intoSetId, params IRedisSortedSet[] setIds) + public long StoreUnionFromSortedSets(IRedisSortedSet intoSetId, params IRedisSortedSet[] setIds) { return client.StoreUnionFromSortedSets(intoSetId.Id, setIds.ConvertAll(x => x.Id).ToArray()); } diff --git a/src/ServiceStack.Redis/Pipeline/RedisPipelineCommand.cs b/src/ServiceStack.Redis/Pipeline/RedisPipelineCommand.cs index d3e52ff7..d68dde1f 100644 --- a/src/ServiceStack.Redis/Pipeline/RedisPipelineCommand.cs +++ b/src/ServiceStack.Redis/Pipeline/RedisPipelineCommand.cs @@ -19,9 +19,9 @@ public void WriteCommand(params byte[][] cmdWithBinaryArgs) cmdCount++; } - public List ReadAllAsInts() + public List ReadAllAsInts() { - var results = new List(); + var results = new List(); while (cmdCount-- > 0) { results.Add(client.ReadInt()); diff --git a/src/ServiceStack.Redis/RedisClient.cs b/src/ServiceStack.Redis/RedisClient.cs index a0b8c020..9f339db8 100644 --- a/src/ServiceStack.Redis/RedisClient.cs +++ b/src/ServiceStack.Redis/RedisClient.cs @@ -236,7 +236,7 @@ public long DecrementValueBy(string key, int count) return DecrBy(key, count); } - public int AppendToValue(string key, string value) + public long AppendToValue(string key, string value) { return base.Append(key, value.ToUtf8Bytes()); } @@ -409,7 +409,7 @@ public IRedisSubscription CreateSubscription() return new RedisSubscription(this); } - public int PublishMessage(string toChannel, string message) + public long PublishMessage(string toChannel, string message) { return base.Publish(toChannel, message.ToUtf8Bytes()); } @@ -708,22 +708,22 @@ internal string UrnKey(Type type, object id) #region LUA EVAL - public int ExecLuaAsInt(string body, params string[] args) + public long ExecLuaAsInt(string body, params string[] args) { return base.EvalInt(body, 0, args.ToMultiByteArray()); } - public int ExecLuaAsInt(string luaBody, string[] keys, string[] args) + public long ExecLuaAsInt(string luaBody, string[] keys, string[] args) { return base.EvalInt(luaBody, keys.Length, MergeAndConvertToBytes(keys, args)); } - public int ExecLuaShaAsInt(string sha1, params string[] args) + public long ExecLuaShaAsInt(string sha1, params string[] args) { return base.EvalShaInt(sha1, args.Length, args.ToMultiByteArray()); } - public int ExecLuaShaAsInt(string sha1, string[] keys, string[] args) + public long ExecLuaShaAsInt(string sha1, string[] keys, string[] args) { return base.EvalShaInt(sha1, keys.Length, MergeAndConvertToBytes(keys, args)); } diff --git a/src/ServiceStack.Redis/RedisClientHash.cs b/src/ServiceStack.Redis/RedisClientHash.cs index bfba4ec3..06526bc6 100644 --- a/src/ServiceStack.Redis/RedisClientHash.cs +++ b/src/ServiceStack.Redis/RedisClientHash.cs @@ -57,7 +57,7 @@ public void AddRange(IEnumerable> items) client.SetRangeInHash(hashId, items); } - public int IncrementValue(string key, int incrementBy) + public long IncrementValue(string key, int incrementBy) { return client.IncrementValueInHash(hashId, key, incrementBy); } @@ -97,7 +97,7 @@ public bool Remove(KeyValuePair item) public int Count { - get { return client.GetHashCount(hashId); } + get { return (int)client.GetHashCount(hashId); } } public bool IsReadOnly diff --git a/src/ServiceStack.Redis/RedisClientList.cs b/src/ServiceStack.Redis/RedisClientList.cs index 8f77a250..36d07618 100644 --- a/src/ServiceStack.Redis/RedisClientList.cs +++ b/src/ServiceStack.Redis/RedisClientList.cs @@ -99,7 +99,7 @@ public int Count { get { - return client.GetListCount(listId); + return (int)client.GetListCount(listId); } } @@ -163,12 +163,12 @@ public void Trim(int keepStartingFrom, int keepEndingAt) client.TrimList(listId, keepStartingFrom, keepEndingAt); } - public int RemoveValue(string value) + public long RemoveValue(string value) { return client.RemoveItemFromList(listId, value); } - public int RemoveValue(string value, int noOfMatches) + public long RemoveValue(string value, int noOfMatches) { return client.RemoveItemFromList(listId, value, noOfMatches); } diff --git a/src/ServiceStack.Redis/RedisClientSet.cs b/src/ServiceStack.Redis/RedisClientSet.cs index f5128008..09bf9a15 100644 --- a/src/ServiceStack.Redis/RedisClientSet.cs +++ b/src/ServiceStack.Redis/RedisClientSet.cs @@ -91,7 +91,7 @@ public int Count { get { - return client.GetSetCount(setId); + return (int)client.GetSetCount(setId); } } diff --git a/src/ServiceStack.Redis/RedisClientSortedSet.cs b/src/ServiceStack.Redis/RedisClientSortedSet.cs index c55d9d29..d1fad188 100644 --- a/src/ServiceStack.Redis/RedisClientSortedSet.cs +++ b/src/ServiceStack.Redis/RedisClientSortedSet.cs @@ -91,7 +91,7 @@ public int Count { get { - return client.GetSortedSetCount(setId); + return (int)client.GetSortedSetCount(setId); } } @@ -152,7 +152,7 @@ public void StoreFromUnion(params IRedisSortedSet[] ofSets) client.StoreUnionFromSets(setId, ofSets.GetIds()); } - public int GetItemIndex(string value) + public long GetItemIndex(string value) { return client.GetItemIndexInSortedSet(setId, value); } diff --git a/src/ServiceStack.Redis/RedisClient_Hash.cs b/src/ServiceStack.Redis/RedisClient_Hash.cs index 9d3fb33a..9e729068 100644 --- a/src/ServiceStack.Redis/RedisClient_Hash.cs +++ b/src/ServiceStack.Redis/RedisClient_Hash.cs @@ -76,12 +76,12 @@ public void SetRangeInHash(string hashId, IEnumerable GetRangeFromSortedSetByHighestScore(string setId, long fromS - public int RemoveRangeFromSortedSet(string setId, int minRank, int maxRank) + public long RemoveRangeFromSortedSet(string setId, int minRank, int maxRank) { return base.ZRemRangeByRank(setId, minRank, maxRank); } - public int RemoveRangeFromSortedSetByScore(string setId, double fromScore, double toScore) + public long RemoveRangeFromSortedSetByScore(string setId, double fromScore, double toScore) { return base.ZRemRangeByScore(setId, fromScore, toScore); } - public int RemoveRangeFromSortedSetByScore(string setId, long fromScore, long toScore) + public long RemoveRangeFromSortedSetByScore(string setId, long fromScore, long toScore) { return base.ZRemRangeByScore(setId, fromScore, toScore); } - public int GetSortedSetCount(string setId) + public long GetSortedSetCount(string setId) { return base.ZCard(setId); } - public int GetSortedSetCount(string setId, string fromStringScore, string toStringScore) + public long GetSortedSetCount(string setId, string fromStringScore, string toStringScore) { var fromScore = GetLexicalScore(fromStringScore); var toScore = GetLexicalScore(toStringScore); return GetSortedSetCount(setId, fromScore, toScore); } - public int GetSortedSetCount(string setId, double fromScore, double toScore) + public long GetSortedSetCount(string setId, double fromScore, double toScore) { return base.ZCount(setId, fromScore, toScore); } - public int GetSortedSetCount(string setId, long fromScore, long toScore) + public long GetSortedSetCount(string setId, long fromScore, long toScore) { return base.ZCount(setId, fromScore, toScore); } @@ -408,12 +408,12 @@ public double GetItemScoreInSortedSet(string setId, string value) return base.ZScore(setId, value.ToUtf8Bytes()); } - public int StoreIntersectFromSortedSets(string intoSetId, params string[] setIds) + public long StoreIntersectFromSortedSets(string intoSetId, params string[] setIds) { return base.ZInterStore(intoSetId, setIds); } - public int StoreUnionFromSortedSets(string intoSetId, params string[] setIds) + public long StoreUnionFromSortedSets(string intoSetId, params string[] setIds) { return base.ZUnionStore(intoSetId, setIds); } diff --git a/src/ServiceStack.Redis/RedisNativeClient.cs b/src/ServiceStack.Redis/RedisNativeClient.cs index 685b61c5..aeace7ef 100644 --- a/src/ServiceStack.Redis/RedisNativeClient.cs +++ b/src/ServiceStack.Redis/RedisNativeClient.cs @@ -63,7 +63,7 @@ public partial class RedisNativeClient internal int IdleTimeOutSecs = 240; //default on redis is 300 internal long LastConnectedAtTimestamp; - public int Id { get; set; } + public long Id { get; set; } public string Host { get; private set; } public int Port { get; private set; } @@ -134,8 +134,8 @@ public RedisNativeClient() #region Common Operations - int db; - public int Db + long db; + public long Db { get { @@ -148,11 +148,11 @@ public int Db } } - public int DbSize + public long DbSize { get { - return SendExpectInt(Commands.DbSize); + return SendExpectLong(Commands.DbSize); } } @@ -160,7 +160,7 @@ public DateTime LastSave { get { - var t = SendExpectInt(Commands.LastSave); + var t = SendExpectLong(Commands.LastSave); return DateTimeExtensions.FromUnixTime(t); } } @@ -268,15 +268,15 @@ public bool Move(string key, int db) if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Move, key.ToUtf8Bytes(), db.ToUtf8Bytes()) == Success; + return SendExpectLong(Commands.Move, key.ToUtf8Bytes(), db.ToUtf8Bytes()) == Success; } - public int ObjectIdleTime(string key) + public long ObjectIdleTime(string key) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Object, Commands.IdleTime, key.ToUtf8Bytes()); + return SendExpectLong(Commands.Object, Commands.IdleTime, key.ToUtf8Bytes()); } public string Type(string key) @@ -307,12 +307,12 @@ public RedisKeyType GetEntryType(string key) throw CreateResponseError("Invalid value"); } - public int StrLen(string key) + public long StrLen(string key) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.StrLen, key.ToUtf8Bytes()); + return SendExpectLong(Commands.StrLen, key.ToUtf8Bytes()); } public void Set(string key, byte[] value) @@ -344,7 +344,7 @@ public bool Persist(string key) if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Persist, key.ToUtf8Bytes()) == Success; + return SendExpectLong(Commands.Persist, key.ToUtf8Bytes()) == Success; } public void PSetEx(string key, long expireInMs, byte[] value) @@ -355,7 +355,7 @@ public void PSetEx(string key, long expireInMs, byte[] value) SendExpectSuccess(Commands.PSetEx, expireInMs.ToUtf8Bytes(), key.ToUtf8Bytes(), value); } - public int SetNX(string key, byte[] value) + public long SetNX(string key, byte[] value) { if (key == null) throw new ArgumentNullException("key"); @@ -364,7 +364,7 @@ public int SetNX(string key, byte[] value) if (value.Length > OneGb) throw new ArgumentException("value exceeds 1G", "value"); - return SendExpectInt(Commands.SetNx, key.ToUtf8Bytes(), value); + return SendExpectLong(Commands.SetNx, key.ToUtf8Bytes(), value); } public void MSet(byte[][] keys, byte[][] values) @@ -383,7 +383,7 @@ public bool MSetNx(byte[][] keys, byte[][] values) { var keysAndValues = MergeCommandWithKeysAndValues(Commands.MSet, keys, values); - return SendExpectInt(keysAndValues) == Success; + return SendExpectLong(keysAndValues) == Success; } public bool MSetNx(string[] keys, byte[][] values) @@ -430,29 +430,29 @@ public byte[] GetSet(string key, byte[] value) return SendExpectData(Commands.GetSet, key.ToUtf8Bytes(), value); } - public int Exists(string key) + public long Exists(string key) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Exists, key.ToUtf8Bytes()); + return SendExpectLong(Commands.Exists, key.ToUtf8Bytes()); } - public int Del(string key) + public long Del(string key) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Del, key.ToUtf8Bytes()); + return SendExpectLong(Commands.Del, key.ToUtf8Bytes()); } - public int Del(params string[] keys) + public long Del(params string[] keys) { if (keys == null) throw new ArgumentNullException("keys"); var cmdWithArgs = MergeCommandWithArgs(Commands.Del, keys); - return SendExpectInt(cmdWithArgs); + return SendExpectLong(cmdWithArgs); } public long Incr(string key) @@ -495,12 +495,12 @@ public long DecrBy(string key, int count) return SendExpectLong(Commands.DecrBy, key.ToUtf8Bytes(), count.ToUtf8Bytes()); } - public int Append(string key, byte[] value) + public long Append(string key, byte[] value) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Append, key.ToUtf8Bytes(), value); + return SendExpectLong(Commands.Append, key.ToUtf8Bytes(), value); } public byte[] Substr(string key, int fromIndex, int toIndex) @@ -519,23 +519,23 @@ public byte[] GetRange(string key, int fromIndex, int toIndex) return SendExpectData(Commands.GetRange, key.ToUtf8Bytes(), fromIndex.ToUtf8Bytes(), toIndex.ToUtf8Bytes()); } - public int SetRange(string key, int offset, byte[] value) + public long SetRange(string key, int offset, byte[] value) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.SetRange, key.ToUtf8Bytes(), offset.ToUtf8Bytes(), value); + return SendExpectLong(Commands.SetRange, key.ToUtf8Bytes(), offset.ToUtf8Bytes(), value); } - public int GetBit(string key, int offset) + public long GetBit(string key, int offset) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.GetBit, key.ToUtf8Bytes(), offset.ToUtf8Bytes()); + return SendExpectLong(Commands.GetBit, key.ToUtf8Bytes(), offset.ToUtf8Bytes()); } - public int SetBit(string key, int offset, int value) + public long SetBit(string key, int offset, int value) { if (key == null) throw new ArgumentNullException("key"); @@ -543,7 +543,7 @@ public int SetBit(string key, int offset, int value) if (value > 1 || value < 0) throw new ArgumentException("value is out of range"); - return SendExpectInt(Commands.SetBit, key.ToUtf8Bytes(), offset.ToUtf8Bytes(), value.ToUtf8Bytes()); + return SendExpectLong(Commands.SetBit, key.ToUtf8Bytes(), offset.ToUtf8Bytes(), value.ToUtf8Bytes()); } public string RandomKey() @@ -568,7 +568,7 @@ public bool RenameNx(string oldKeyname, string newKeyname) if (newKeyname == null) throw new ArgumentNullException("newKeyname"); - return SendExpectInt(Commands.RenameNx, oldKeyname.ToUtf8Bytes(), newKeyname.ToUtf8Bytes()) == Success; + return SendExpectLong(Commands.RenameNx, oldKeyname.ToUtf8Bytes(), newKeyname.ToUtf8Bytes()) == Success; } public bool Expire(string key, int seconds) @@ -576,7 +576,7 @@ public bool Expire(string key, int seconds) if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Expire, key.ToUtf8Bytes(), seconds.ToUtf8Bytes()) == Success; + return SendExpectLong(Commands.Expire, key.ToUtf8Bytes(), seconds.ToUtf8Bytes()) == Success; } public bool PExpire(string key, long ttlMs) @@ -584,7 +584,7 @@ public bool PExpire(string key, long ttlMs) if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.PExpire, key.ToUtf8Bytes(), ttlMs.ToUtf8Bytes()) == Success; + return SendExpectLong(Commands.PExpire, key.ToUtf8Bytes(), ttlMs.ToUtf8Bytes()) == Success; } public bool ExpireAt(string key, long unixTime) @@ -592,7 +592,7 @@ public bool ExpireAt(string key, long unixTime) if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.ExpireAt, key.ToUtf8Bytes(), unixTime.ToUtf8Bytes()) == Success; + return SendExpectLong(Commands.ExpireAt, key.ToUtf8Bytes(), unixTime.ToUtf8Bytes()) == Success; } public bool PExpireAt(string key, long unixTimeMs) @@ -600,15 +600,15 @@ public bool PExpireAt(string key, long unixTimeMs) if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.PExpireAt, key.ToUtf8Bytes(), unixTimeMs.ToUtf8Bytes()) == Success; + return SendExpectLong(Commands.PExpireAt, key.ToUtf8Bytes(), unixTimeMs.ToUtf8Bytes()) == Success; } - public int Ttl(string key) + public long Ttl(string key) { if (key == null) throw new ArgumentNullException("key"); - return SendExpectInt(Commands.Ttl, key.ToUtf8Bytes()); + return SendExpectLong(Commands.Ttl, key.ToUtf8Bytes()); } public long PTtl(string key) @@ -758,18 +758,18 @@ public byte[][] SMembers(string setId) return SendExpectMultiData(Commands.SMembers, setId.ToUtf8Bytes()); } - public int SAdd(string setId, byte[] value) + public long SAdd(string setId, byte[] value) { AssertSetIdAndValue(setId, value); - return SendExpectInt(Commands.SAdd, setId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.SAdd, setId.ToUtf8Bytes(), value); } - public int SRem(string setId, byte[] value) + public long SRem(string setId, byte[] value) { AssertSetIdAndValue(setId, value); - return SendExpectInt(Commands.SRem, setId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.SRem, setId.ToUtf8Bytes(), value); } public byte[] SPop(string setId) @@ -790,20 +790,20 @@ public void SMove(string fromSetId, string toSetId, byte[] value) SendExpectSuccess(Commands.SMove, fromSetId.ToUtf8Bytes(), toSetId.ToUtf8Bytes(), value); } - public int SCard(string setId) + public long SCard(string setId) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.SCard, setId.ToUtf8Bytes()); + return SendExpectLong(Commands.SCard, setId.ToUtf8Bytes()); } - public int SIsMember(string setId, byte[] value) + public long SIsMember(string setId, byte[] value) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.SIsMember, setId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.SIsMember, setId.ToUtf8Bytes(), value); } public byte[][] SInter(params string[] setIds) @@ -918,26 +918,26 @@ public byte[][] Sort(string listOrSetId, SortOptions sortOptions) return SendExpectMultiData(cmdWithArgs.ToArray()); } - public int RPush(string listId, byte[] value) + public long RPush(string listId, byte[] value) { AssertListIdAndValue(listId, value); - return SendExpectInt(Commands.RPush, listId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.RPush, listId.ToUtf8Bytes(), value); } - public int RPushX(string listId, byte[] value) + public long RPushX(string listId, byte[] value) { throw new NotImplementedException(); } - public int LPush(string listId, byte[] value) + public long LPush(string listId, byte[] value) { AssertListIdAndValue(listId, value); - return SendExpectInt(Commands.LPush, listId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.LPush, listId.ToUtf8Bytes(), value); } - public int LPushX(string listId, byte[] value) + public long LPushX(string listId, byte[] value) { throw new NotImplementedException(); } @@ -950,20 +950,20 @@ public void LTrim(string listId, int keepStartingFrom, int keepEndingAt) SendExpectSuccess(Commands.LTrim, listId.ToUtf8Bytes(), keepStartingFrom.ToUtf8Bytes(), keepEndingAt.ToUtf8Bytes()); } - public int LRem(string listId, int removeNoOfMatches, byte[] value) + public long LRem(string listId, int removeNoOfMatches, byte[] value) { if (listId == null) throw new ArgumentNullException("listId"); - return SendExpectInt(Commands.LRem, listId.ToUtf8Bytes(), removeNoOfMatches.ToUtf8Bytes(), value); + return SendExpectLong(Commands.LRem, listId.ToUtf8Bytes(), removeNoOfMatches.ToUtf8Bytes(), value); } - public int LLen(string listId) + public long LLen(string listId) { if (listId == null) throw new ArgumentNullException("listId"); - return SendExpectInt(Commands.LLen, listId.ToUtf8Bytes()); + return SendExpectLong(Commands.LLen, listId.ToUtf8Bytes()); } public byte[] LIndex(string listId, int listIndex) @@ -1112,25 +1112,25 @@ private static void AssertSetIdAndValue(string setId, byte[] value) throw new ArgumentNullException("value"); } - public int ZAdd(string setId, double score, byte[] value) + public long ZAdd(string setId, double score, byte[] value) { AssertSetIdAndValue(setId, value); - return SendExpectInt(Commands.ZAdd, setId.ToUtf8Bytes(), score.ToFastUtf8Bytes(), value); + return SendExpectLong(Commands.ZAdd, setId.ToUtf8Bytes(), score.ToFastUtf8Bytes(), value); } - public int ZAdd(string setId, long score, byte[] value) + public long ZAdd(string setId, long score, byte[] value) { AssertSetIdAndValue(setId, value); - return SendExpectInt(Commands.ZAdd, setId.ToUtf8Bytes(), score.ToUtf8Bytes(), value); + return SendExpectLong(Commands.ZAdd, setId.ToUtf8Bytes(), score.ToUtf8Bytes(), value); } - public int ZRem(string setId, byte[] value) + public long ZRem(string setId, byte[] value) { AssertSetIdAndValue(setId, value); - return SendExpectInt(Commands.ZRem, setId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.ZRem, setId.ToUtf8Bytes(), value); } public double ZIncrBy(string setId, double incrBy, byte[] value) @@ -1147,18 +1147,18 @@ public double ZIncrBy(string setId, long incrBy, byte[] value) return SendExpectDouble(Commands.ZIncrBy, setId.ToUtf8Bytes(), incrBy.ToUtf8Bytes(), value); } - public int ZRank(string setId, byte[] value) + public long ZRank(string setId, byte[] value) { AssertSetIdAndValue(setId, value); - return SendExpectInt(Commands.ZRank, setId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.ZRank, setId.ToUtf8Bytes(), value); } - public int ZRevRank(string setId, byte[] value) + public long ZRevRank(string setId, byte[] value) { AssertSetIdAndValue(setId, value); - return SendExpectInt(Commands.ZRevRank, setId.ToUtf8Bytes(), value); + return SendExpectLong(Commands.ZRevRank, setId.ToUtf8Bytes(), value); } private byte[][] GetRange(byte[] commandBytes, string setId, int min, int max, bool withScores) @@ -1295,55 +1295,55 @@ public byte[][] ZRevRangeByScoreWithScores(string setId, long min, long max, int return GetRangeByScore(Commands.ZRevRangeByScore, setId, max, min, skip, take, true); } - public int ZRemRangeByRank(string setId, int min, int max) + public long ZRemRangeByRank(string setId, int min, int max) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.ZRemRangeByRank, setId.ToUtf8Bytes(), + return SendExpectLong(Commands.ZRemRangeByRank, setId.ToUtf8Bytes(), min.ToUtf8Bytes(), max.ToUtf8Bytes()); } - public int ZRemRangeByScore(string setId, double fromScore, double toScore) + public long ZRemRangeByScore(string setId, double fromScore, double toScore) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.ZRemRangeByScore, setId.ToUtf8Bytes(), + return SendExpectLong(Commands.ZRemRangeByScore, setId.ToUtf8Bytes(), fromScore.ToFastUtf8Bytes(), toScore.ToFastUtf8Bytes()); } - public int ZRemRangeByScore(string setId, long fromScore, long toScore) + public long ZRemRangeByScore(string setId, long fromScore, long toScore) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.ZRemRangeByScore, setId.ToUtf8Bytes(), + return SendExpectLong(Commands.ZRemRangeByScore, setId.ToUtf8Bytes(), fromScore.ToUtf8Bytes(), toScore.ToUtf8Bytes()); } - public int ZCard(string setId) + public long ZCard(string setId) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.ZCard, setId.ToUtf8Bytes()); + return SendExpectLong(Commands.ZCard, setId.ToUtf8Bytes()); } - public int ZCount(string setId, double min, double max) + public long ZCount(string setId, double min, double max) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.ZCount, setId.ToUtf8Bytes(), min.ToUtf8Bytes(), max.ToUtf8Bytes()); + return SendExpectLong(Commands.ZCount, setId.ToUtf8Bytes(), min.ToUtf8Bytes(), max.ToUtf8Bytes()); } - public int ZCount(string setId, long min, long max) + public long ZCount(string setId, long min, long max) { if (setId == null) throw new ArgumentNullException("setId"); - return SendExpectInt(Commands.ZCount, setId.ToUtf8Bytes(), min.ToUtf8Bytes(), max.ToUtf8Bytes()); + return SendExpectLong(Commands.ZCount, setId.ToUtf8Bytes(), min.ToUtf8Bytes(), max.ToUtf8Bytes()); } public double ZScore(string setId, byte[] value) @@ -1354,24 +1354,24 @@ public double ZScore(string setId, byte[] value) return SendExpectDouble(Commands.ZScore, setId.ToUtf8Bytes(), value); } - public int ZUnionStore(string intoSetId, params string[] setIds) + public long ZUnionStore(string intoSetId, params string[] setIds) { var setIdsList = new List(setIds); setIdsList.Insert(0, setIds.Length.ToString()); setIdsList.Insert(0, intoSetId); var cmdWithArgs = MergeCommandWithArgs(Commands.ZUnionStore, setIdsList.ToArray()); - return SendExpectInt(cmdWithArgs); + return SendExpectLong(cmdWithArgs); } - public int ZInterStore(string intoSetId, params string[] setIds) + public long ZInterStore(string intoSetId, params string[] setIds) { var setIdsList = new List(setIds); setIdsList.Insert(0, setIds.Length.ToString()); setIdsList.Insert(0, intoSetId); var cmdWithArgs = MergeCommandWithArgs(Commands.ZInterStore, setIdsList.ToArray()); - return SendExpectInt(cmdWithArgs); + return SendExpectLong(cmdWithArgs); } #endregion @@ -1387,18 +1387,18 @@ private static void AssertHashIdAndKey(string hashId, byte[] key) throw new ArgumentNullException("key"); } - public int HSet(string hashId, byte[] key, byte[] value) + public long HSet(string hashId, byte[] key, byte[] value) { AssertHashIdAndKey(hashId, key); - return SendExpectInt(Commands.HSet, hashId.ToUtf8Bytes(), key, value); + return SendExpectLong(Commands.HSet, hashId.ToUtf8Bytes(), key, value); } - public int HSetNX(string hashId, byte[] key, byte[] value) + public long HSetNX(string hashId, byte[] key, byte[] value) { AssertHashIdAndKey(hashId, key); - return SendExpectInt(Commands.HSetNx, hashId.ToUtf8Bytes(), key, value); + return SendExpectLong(Commands.HSetNx, hashId.ToUtf8Bytes(), key, value); } public void HMSet(string hashId, byte[][] keys, byte[][] values) @@ -1411,18 +1411,18 @@ public void HMSet(string hashId, byte[][] keys, byte[][] values) SendExpectSuccess(cmdArgs); } - public int HIncrby(string hashId, byte[] key, int incrementBy) + public long HIncrby(string hashId, byte[] key, int incrementBy) { AssertHashIdAndKey(hashId, key); - return SendExpectInt(Commands.HIncrBy, hashId.ToUtf8Bytes(), key, incrementBy.ToString().ToUtf8Bytes()); + return SendExpectLong(Commands.HIncrBy, hashId.ToUtf8Bytes(), key, incrementBy.ToString().ToUtf8Bytes()); } - public int HIncrby(string hashId, byte[] key, long incrementBy) + public long HIncrby(string hashId, byte[] key, long incrementBy) { AssertHashIdAndKey(hashId, key); - return SendExpectInt(Commands.HIncrBy, hashId.ToUtf8Bytes(), key, incrementBy.ToString().ToUtf8Bytes()); + return SendExpectLong(Commands.HIncrBy, hashId.ToUtf8Bytes(), key, incrementBy.ToString().ToUtf8Bytes()); } public double HIncrbyFloat(string hashId, byte[] key, double incrementBy) @@ -1451,26 +1451,26 @@ public byte[][] HMGet(string hashId, params byte[][] keys) return SendExpectMultiData(cmdArgs); } - public int HDel(string hashId, byte[] key) + public long HDel(string hashId, byte[] key) { AssertHashIdAndKey(hashId, key); - return SendExpectInt(Commands.HDel, hashId.ToUtf8Bytes(), key); + return SendExpectLong(Commands.HDel, hashId.ToUtf8Bytes(), key); } - public int HExists(string hashId, byte[] key) + public long HExists(string hashId, byte[] key) { AssertHashIdAndKey(hashId, key); - return SendExpectInt(Commands.HExists, hashId.ToUtf8Bytes(), key); + return SendExpectLong(Commands.HExists, hashId.ToUtf8Bytes(), key); } - public int HLen(string hashId) + public long HLen(string hashId) { if (string.IsNullOrEmpty(hashId)) throw new ArgumentNullException("hashId"); - return SendExpectInt(Commands.HLen, hashId.ToUtf8Bytes()); + return SendExpectLong(Commands.HLen, hashId.ToUtf8Bytes()); } public byte[][] HKeys(string hashId) @@ -1497,9 +1497,9 @@ public byte[][] HGetAll(string hashId) return SendExpectMultiData(Commands.HGetAll, hashId.ToUtf8Bytes()); } - public int Publish(string toChannel, byte[] message) + public long Publish(string toChannel, byte[] message) { - return SendExpectInt(Commands.Publish, toChannel.ToUtf8Bytes(), message); + return SendExpectLong(Commands.Publish, toChannel.ToUtf8Bytes(), message); } public byte[][] ReceiveMessages() diff --git a/src/ServiceStack.Redis/RedisNativeClient_Utils.cs b/src/ServiceStack.Redis/RedisNativeClient_Utils.cs index 5f294ad6..d59e4cc9 100644 --- a/src/ServiceStack.Redis/RedisNativeClient_Utils.cs +++ b/src/ServiceStack.Redis/RedisNativeClient_Utils.cs @@ -316,19 +316,6 @@ protected void SendExpectSuccess(params byte[][] cmdWithBinaryArgs) ExpectSuccess(); } - protected int SendExpectInt(params byte[][] cmdWithBinaryArgs) - { - if (!SendCommand(cmdWithBinaryArgs)) - throw CreateConnectionError(); - - if (Pipeline != null) - { - Pipeline.CompleteIntQueuedCommand(ReadInt); - return default(int); - } - return ReadInt(); - } - protected long SendExpectLong(params byte[][] cmdWithBinaryArgs) { if (!SendCommand(cmdWithBinaryArgs)) @@ -336,12 +323,12 @@ protected long SendExpectLong(params byte[][] cmdWithBinaryArgs) if (Pipeline != null) { - Pipeline.CompleteLongQueuedCommand(ReadLong); + Pipeline.CompleteLongQueuedCommand(ReadInt); return default(long); } return ReadLong(); } - + protected byte[] SendExpectData(params byte[][] cmdWithBinaryArgs) { if (!SendCommand(cmdWithBinaryArgs)) @@ -514,7 +501,7 @@ internal void ExpectQueued() ExpectWord("QUEUED"); } - public int ReadInt() + public long ReadInt() { int c = SafeReadByte(); if (c == -1) @@ -825,22 +812,22 @@ protected byte[][] MergeAndConvertToBytes(string[] keys, string[] args) return ConvertToBytes(merged); } - public int EvalInt(string luaBody, int numberKeysInArgs, params byte[][] keys) + public long EvalInt(string luaBody, int numberKeysInArgs, params byte[][] keys) { if (luaBody == null) throw new ArgumentNullException("luaBody"); var cmdArgs = MergeCommandWithArgs(Commands.Eval, luaBody.ToUtf8Bytes(), keys.PrependInt(numberKeysInArgs)); - return SendExpectInt(cmdArgs); + return SendExpectLong(cmdArgs); } - public int EvalShaInt(string sha1, int numberKeysInArgs, params byte[][] keys) + public long EvalShaInt(string sha1, int numberKeysInArgs, params byte[][] keys) { if (sha1 == null) throw new ArgumentNullException("sha1"); var cmdArgs = MergeCommandWithArgs(Commands.EvalSha, sha1.ToUtf8Bytes(), keys.PrependInt(numberKeysInArgs)); - return SendExpectInt(cmdArgs); + return SendExpectLong(cmdArgs); } public string EvalStr(string luaBody, int numberKeysInArgs, params byte[][] keys) diff --git a/src/ServiceStack.Redis/RedisSubscription.cs b/src/ServiceStack.Redis/RedisSubscription.cs index de494b7d..c90e6de3 100644 --- a/src/ServiceStack.Redis/RedisSubscription.cs +++ b/src/ServiceStack.Redis/RedisSubscription.cs @@ -10,7 +10,7 @@ public class RedisSubscription { private readonly IRedisNativeClient redisClient; private List activeChannels; - public int SubscriptionCount { get; private set; } + public long SubscriptionCount { get; private set; } public bool IsPSubscription { get; private set; } private const int MsgIndex = 2; diff --git a/src/ServiceStack.Redis/Support/Locking/DistributedLock.cs b/src/ServiceStack.Redis/Support/Locking/DistributedLock.cs index 5bca7d51..828b0912 100644 --- a/src/ServiceStack.Redis/Support/Locking/DistributedLock.cs +++ b/src/ServiceStack.Redis/Support/Locking/DistributedLock.cs @@ -33,7 +33,7 @@ public virtual long Lock(string key, int acquisitionTimeout, int lockTimeout, ou var newLockExpire = CalculateLockExpire(ts, lockTimeout); var localClient = (RedisClient)client; - int wasSet = localClient.SetNX(key, BitConverter.GetBytes(newLockExpire)); + long wasSet = localClient.SetNX(key, BitConverter.GetBytes(newLockExpire)); int totalTime = 0; while (wasSet == LOCK_NOT_ACQUIRED && totalTime < acquisitionTimeout) { diff --git a/tests/ServiceStack.Redis.Tests/RedisClientHashTests.cs b/tests/ServiceStack.Redis.Tests/RedisClientHashTests.cs index 2f785b5d..d4245553 100644 --- a/tests/ServiceStack.Redis.Tests/RedisClientHashTests.cs +++ b/tests/ServiceStack.Redis.Tests/RedisClientHashTests.cs @@ -192,6 +192,16 @@ public void Can_increment_Hash_field() Assert.That(members, Is.EquivalentTo(ToStringMap(stringIntMap))); } + [Test] + public void Can_increment_Hash_field_beyond_32_bits() + { + Redis.SetEntryInHash(HashId, "int", Int32.MaxValue.ToString()); + Redis.IncrementValueInHash(HashId, "int", 1); + long actual = Int64.Parse(Redis.GetValueFromHash(HashId, "int")); + long expected = Int32.MaxValue + 1L; + Assert.That(actual, Is.EqualTo(expected)); + } + [Test] public void Can_SetItemInHashIfNotExists() {