phpssdb是用C实现的SSDB的PHP扩展客户端。
示例代码:
$ssdb_handle = new SSDB(); $ssdb_handle->connect('127.0.0.1', 8888);$ssdb_handle->set('ssdb_version', '1.8.0');$ssdb_handle->get('ssdb_version');本扩展支持的所有命令如果返回为NULL,代表可能的错误为命令参数错误、连接中断、服务器返回失败、客户端发送失败等
本扩展还提供了一个附近查询
//添加坐标$ssdb_handle->geo_set('geo_test','a',31.197452,121.515095);$ssdb_handle->geo_set('geo_test','b',31.196456,121.515778);$ssdb_handle->geo_set('geo_test','c',31.197159,121.518015);$ssdb_handle->geo_set('geo_test','d',31.196282,121.51563);$ssdb_handle->geo_set('geo_test','e',31.203159,121.518082);//查询b附近点距离不大于4000米,最大返回数量不超过10个$result=$ssdb_handle->geo_neighbour('geo_test','b',4000,10);print_r($result);//距离echo$ssdb_handle->geo_distance('geo_test','a','b');
评论