Node.js 有没有办法在redis Service上的GEOADD方法中添加Date属性
需要以下geoadd代码的帮助吗Node.js 有没有办法在redis Service上的GEOADD方法中添加Date属性,node.js,redis,node-redis,Node.js,Redis,Node Redis,需要以下geoadd代码的帮助吗 _ client.geoadd('drivers_locations', coordinates[0], coordinates[1], driverID ,new Date().toString()); 否,没有可用于的时间维度 根据您正在做的事情,您可以通过将时间按不同的键来模拟它,如 const key = `drivers_locations_${Math.floor(+new Date() / 1000 / 60)`; client.geoadd(k
_ client.geoadd('drivers_locations', coordinates[0], coordinates[1], driverID ,new Date().toString());
否,没有可用于的时间维度 根据您正在做的事情,您可以通过将时间按不同的键来模拟它,如
const key = `drivers_locations_${Math.floor(+new Date() / 1000 / 60)`;
client.geoadd(key, lon, lat, driverID);
但是查询变得更加复杂。虽然
GEOADD
不支持此功能,但您可以将日期属性存储在另一个键中,例如:
client.geoadd('drivers_locations', coordinates[0], coordinates[1], driverID);
client.hset('driver:' + id, 'date', ,ew Date().toString());
在redis中是否有其他方法可用于根据键添加/更新和获取日期属性?这取决于你最终想要实现什么。