From 85d80bf6bf9df718a778af44de7de2689cec15e7 Mon Sep 17 00:00:00 2001 From: Memoyu Date: Sat, 13 Apr 2024 11:22:06 +0800 Subject: [PATCH] fix: SE 2.7.33 after returns Position is zero if it does not exist --- .../DefaultRedisCachingProvider.Geo.cs | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 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;