Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 66b6e93

Browse files
authored
Merge pull request #243 from Naragato/master
Add extra numeric types to collection and rename field
2 parents e02ef5a + 73aeaa5 commit 66b6e93

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ServiceStack.Redis/RedisClient.ICacheClient.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public T Get<T>(string key)
5353
}
5454

5555
//Looking up Dictionary<Type,bool> for type is faster than HashSet<Type>.
56-
private static Dictionary<Type, bool> integralTypes = new Dictionary<Type, bool> {
56+
private static readonly Dictionary<Type, bool> numericTypes = new Dictionary<Type, bool> {
5757
{ typeof(byte), true},
5858
{ typeof(sbyte), true},
5959
{ typeof(short), true},
@@ -62,12 +62,15 @@ public T Get<T>(string key)
6262
{ typeof(uint), true},
6363
{ typeof(long), true},
6464
{ typeof(ulong), true},
65+
{ typeof(double), true},
66+
{ typeof(float), true},
67+
{ typeof(decimal), true}
6568
};
6669

6770
private static byte[] ToBytes<T>(T value)
6871
{
6972
var bytesValue = value as byte[];
70-
if (bytesValue == null && (integralTypes.ContainsKey(typeof(T)) || !Equals(value, default(T))))
73+
if (bytesValue == null && (numericTypes.ContainsKey(typeof(T)) || !Equals(value, default(T))))
7174
bytesValue = value.ToJson().ToUtf8Bytes();
7275
return bytesValue;
7376
}

0 commit comments

Comments
 (0)