Skip to content

Commit 0fd0209

Browse files
author
Alexander Cheprasov
committed
Added command GEODEL
1 parent f1168c0 commit 0fd0209

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/RedisClient/Command/Traits/Version3x2/GeoCommandsTrait.php

+13
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,17 @@ public function georadiusbymember($key, $member, $radius, $unit, $withcoord = fa
174174
return $this->returnCommand(['GEORADIUSBYMEMBER'], $params, $parse ? ResponseParser::PARSE_GEO_ARRAY : null);
175175
}
176176

177+
/**
178+
* GEODEL key member [member ...]
179+
* @link https://github.com/antirez/redis-doc/commit/0f0db1548bef3e005e775ead79b5b9c13be4baed
180+
* @see \RedisClient\Command\Traits\Version2x6\SortedSetsCommandsTrait::zrem
181+
*
182+
* @param string $key
183+
* @param string|string[] $members
184+
* @return int The number of members removed from the sorted set, not including non existing members.
185+
*/
186+
public function geodel($key, $members) {
187+
return $this->zrem($key, $members);
188+
}
189+
177190
}

tests/Integration/Version3x2/GeoCommandsTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,37 @@ public function test_georadiusbymember() {
266266
}
267267
}
268268

269+
270+
/**
271+
* @see GeoCommandsTrait::geodel
272+
*/
273+
public function test_geodel() {
274+
$Redis = static::$Redis;
275+
276+
$this->assertSame(3, $Redis->geoadd('Sicily', [
277+
'Agrigento' => ['13.583333', '37.316667'],
278+
'Palermo' => ['13.361389', '38.115556'],
279+
'Catania' => ['15.087269', '37.502669']
280+
]));
281+
282+
$this->assertSame(['Agrigento', 'Palermo', 'Catania'], $Redis->georadiusbymember('Sicily', 'Agrigento', 300, 'km', 0, 0, 0, 0, true));
283+
284+
$this->assertSame(1, $Redis->geodel('Sicily', 'Palermo'));
285+
$this->assertSame(['Agrigento', 'Catania'], $Redis->georadiusbymember('Sicily', 'Agrigento', 300, 'km', 0, 0, 0, 0, true));
286+
287+
$this->assertSame(0, $Redis->geodel('Sicily', 'Palermo'));
288+
$this->assertSame(['Agrigento', 'Catania'], $Redis->georadiusbymember('Sicily', 'Agrigento', 300, 'km', 0, 0, 0, 0, true));
289+
290+
$this->assertSame(1, $Redis->geodel('Sicily', ['Catania', 'Catania', 'Palermo']));
291+
$this->assertSame(['Agrigento'], $Redis->georadiusbymember('Sicily', 'Agrigento', 300, 'km', 0, 0, 0, 0, true));
292+
293+
$Redis->set('foo', 'bar');
294+
try {
295+
$Redis->geodel('foo', 'Agrigento');
296+
$this->assertFalse('Expect Exception');
297+
} catch (\Exception $Ex) {
298+
$this->assertInstanceOf(ErrorResponseException::class, $Ex);
299+
}
300+
}
301+
269302
}

0 commit comments

Comments
 (0)