File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -2721,6 +2721,18 @@ def geoadd(key, *member)
2721
2721
end
2722
2722
end
2723
2723
2724
+ # Returns geohash string representing position for specified members of the specified key.
2725
+ #
2726
+ # @param [String] key
2727
+ # @param [String, Array<String>] member one member or array of members
2728
+ # @return [Array<String, nil>] returns array containg geohash string if member is present, nil otherwise
2729
+ def geohash ( key , member )
2730
+ synchronize do |client |
2731
+ client . call ( [ :geohash , key , member ] )
2732
+ end
2733
+ end
2734
+
2735
+
2724
2736
# Query a sorted set representing a geospatial index to fetch members matching a
2725
2737
# given maximum distance from a point
2726
2738
#
Original file line number Diff line number Diff line change @@ -74,4 +74,17 @@ def test_geodist_with_nonexistant_location
74
74
distination = r . geodist ( "Sicily" , "Palermo" , "Rome" )
75
75
assert_equal nil , distination
76
76
end
77
+
78
+ def test_geohash
79
+ geohash = r . geohash ( "Sicily" , "Palermo" )
80
+ assert_equal [ "sqc8b49rny0" ] , geohash
81
+
82
+ geohashes = r . geohash ( "Sicily" , [ "Palermo" , "Catania" ] )
83
+ assert_equal %w( sqc8b49rny0 sqdtr74hyu0 ) , geohashes
84
+ end
85
+
86
+ def test_geohash_with_nonexistant_location
87
+ geohashes = r . geohash ( "Sicily" , [ "Palermo" , "Rome" ] )
88
+ assert_equal [ "sqc8b49rny0" , nil ] , geohashes
89
+ end
77
90
end
You can’t perform that action at this time.
0 commit comments