我正在开发一个显示附近应用用户的iOS应用 . 当用户的位置发生变化时,会将其发送到服务器 . 该应用每隔几分钟轮询一次服务器,以发现当前附近的用户 . 我正在使用Parse,这很好用 . 现在我想用AWS服务替换Parse后端 . 我的想法是在Lambda函数中部署dynamodb-geo库 .

我有一个与dynamodb-geo库一起使用的DynamoDB表 . 它将geoHash作为hashKey . 对于rangeKey,我使用userId . 我可以使用putPoint存储用户的位置:

GeoPoint geoPoint = new GeoPoint(latitude, longitude);
AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(“someUserId”);
PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyAttributeValue);
geoDataManager.putPoint(putPointRequest);

要查找附近的用户,我使用queryRadius函数:

GeoPoint currentPoint = new GeoPoint(latitude, longitude);
QueryRadiusRequest request = new QueryRadiusRequest(currentPoint, radius);
return geoDataManager.queryRadius(request).getItem();

到现在为止还挺好 . 现在来问题了 . 现有用户已移动到其他位置,并将其新位置发送到服务器 . 我如何更新他的位置?我不能使用putPoint或updatePoint函数 . 从updatePoint的javadoc:

更新Amazon DynamoDB表中的点数据 . 您无法更新GeoDataManagerConfiguration中指定的属性:散列键,范围键,geohash和geoJson . 如果要更新这些列,则需要插入新记录并删除旧记录 .

我理解为什么会这样,它是DynamoDB的工作原理 . 我无法更新hashKey . 我必须删除旧项目并添加新项目 . 这个额外的处理引起了一些关于我将lambodb-geo与Lambda一起使用的计划的疑虑:

我想知道我使用带有Lambda的dynamodb-geo提出的解决方案是否是实现我的用例的良好且可扩展的方法 . 我对AWS很陌生,我总是对更好的替代方案的建议感兴趣 .