design / redis-geo
redis geo
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2025-03-23 21:30:43 UTC
README
redis geo
引入包
composer require design/redis-geo
连接redis
use Design\RedisGeo\Geo; $geo = Geo::getInstance(); $geo->init(['host' => '192.168.1.202', 'port' => 9221]);
redis添加成员坐标
$key = 'user_pos'; $pos = [ [ 'lon'=> '121.20955504', 'lat'=> '37.5365615629', 'member'=> '1' ], [ 'lon'=> '121.20955504', 'lat'=> '37.5365615629', 'member'=> '2' ] ]; $geo->geoAdd($key, $pos);
输出坐标范围内的成员
$res = $geo->geoRadiusByMember($key, [ 'member'=> 2, 'dist'=> 2000, 'unit'=> 'km', 'withDist'=> 1 ]); dump($res);