From 914d7e8027fd1202ddb50d9f4ece5e10fc72fa20 Mon Sep 17 00:00:00 2001 From: memoyu Date: Sun, 14 Apr 2024 09:53:09 +0800 Subject: [PATCH] Upgrade StackExchange.Redis version to 2.7.33 (#527) * Upgrade StackExchange.Redis version to 2.7.33 by #526 * fix: SE 2.7.33 after returns Position is zero if it does not exist --- .../DefaultRedisCachingProvider.Geo.cs | 31 ++++++++++++------- .../EasyCaching.Redis.csproj | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/EasyCaching.Redis/DefaultRedisCachingProvider.Geo.cs b/src/EasyCaching.Redis/DefaultRedisCachingProvider.Geo.cs index 8142dcae..6bff2e70 100644 --- a/src/EasyCaching.Redis/DefaultRedisCachingProvider.Geo.cs +++ b/src/EasyCaching.Redis/DefaultRedisCachingProvider.Geo.cs @@ -21,7 +21,7 @@ public long GeoAdd(string cacheKey, List<(double longitude, double latitude, str foreach (var item in values) { - list.Add( new GeoEntry(item.longitude, item.latitude, item.member)); + list.Add(new GeoEntry(item.longitude, item.latitude, item.member)); } var res = _cache.GeoAdd(cacheKey, list.ToArray()); @@ -115,12 +115,17 @@ public async Task> GeoHashAsync(string cacheKey, List membe { if (item.HasValue) { - tuple.Add((Convert.ToDecimal(item.Value.Longitude.ToString()), Convert.ToDecimal(item.Value.Latitude.ToString()))); - } - else - { - tuple.Add(null); + var longitude = Convert.ToDecimal(item.Value.Longitude.ToString()); + var latitude = Convert.ToDecimal(item.Value.Latitude.ToString()); + // returns { Longitude = 0,Latitude = 0 } if it does not exist + if (longitude != 0 && latitude != 0) + { + tuple.Add((longitude, latitude)); + continue; + } } + + tuple.Add(null); } return tuple; @@ -145,13 +150,17 @@ public async Task> GeoHashAsync(string cacheKey, List membe { if (item.HasValue) { - tuple.Add((Convert.ToDecimal(item.Value.Longitude.ToString()), Convert.ToDecimal(item.Value.Latitude.ToString()))); - } - else - { - tuple.Add(null); + var longitude = Convert.ToDecimal(item.Value.Longitude.ToString()); + var latitude = Convert.ToDecimal(item.Value.Latitude.ToString()); + // returns { Longitude = 0,Latitude = 0 } if it does not exist + if (longitude != 0 && latitude != 0) + { + tuple.Add((longitude, latitude)); + continue; + } } + tuple.Add(null); } return tuple; diff --git a/src/EasyCaching.Redis/EasyCaching.Redis.csproj b/src/EasyCaching.Redis/EasyCaching.Redis.csproj index 3c526a83..8c2264be 100644 --- a/src/EasyCaching.Redis/EasyCaching.Redis.csproj +++ b/src/EasyCaching.Redis/EasyCaching.Redis.csproj @@ -33,7 +33,7 @@ - +