Skip to content

Commit 7a84d7d

Browse files
TheSmartnikbadboy
authored andcommitted
Add geoadd
1 parent 32ab539 commit 7a84d7d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/redis.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,17 @@ def pfmerge(dest_key, *source_key)
27102710
end
27112711
end
27122712

2713+
# Adds the specified geospatial items (latitude, longitude, name) to the specified key
2714+
#
2715+
# @param [String] key
2716+
# @param [Array] member arguemnts for member or members: longitude, latitude, name
2717+
# @return [Intger] number of elements added to the sorted set
2718+
def geoadd(key, *member)
2719+
synchronize do |client|
2720+
client.call([:geoadd, key, member])
2721+
end
2722+
end
2723+
27132724
# Query a sorted set representing a geospatial index to fetch members matching a
27142725
# given maximum distance from a point
27152726
#

test/commands_on_geo_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ class TestCommandsGeo < Test::Unit::TestCase
55

66
def setup
77
super
8-
r.geoadd("Sicily", 13.361389, 38.115556, "Palermo", 15.087269, 37.502669, "Catania")
8+
9+
added_items_count = r.geoadd("Sicily", 13.361389, 38.115556, "Palermo", 15.087269, 37.502669, "Catania")
10+
assert_equal 2, added_items_count
911
end
1012

1113
def test_georadius_with_sort

0 commit comments

Comments
 (0)