Skip to content

Commit

Permalink
fix: SE 2.7.33 after returns Position is zero if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Memoyu committed Apr 13, 2024
1 parent baff91e commit 85d80bf
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/EasyCaching.Redis/DefaultRedisCachingProvider.Geo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -115,12 +115,17 @@ public async Task<List<string>> GeoHashAsync(string cacheKey, List<string> 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;
Expand All @@ -145,13 +150,17 @@ public async Task<List<string>> GeoHashAsync(string cacheKey, List<string> 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;
Expand Down

0 comments on commit 85d80bf

Please sign in to comment.