fix: timestamp as score for zadd
This commit is contained in:
@@ -47,7 +47,7 @@ async function store(event) {
|
|||||||
value: event.value, unit: event.unit, location: event.location, timestamp: event.timestamp,
|
value: event.value, unit: event.unit, location: event.location, timestamp: event.timestamp,
|
||||||
}));
|
}));
|
||||||
await r.hIncrBy("iot:counters", event.device_type, 1);
|
await r.hIncrBy("iot:counters", event.device_type, 1);
|
||||||
await r.zAdd("iot:recent", [{ score: 0, value: JSON.stringify(event) }]);
|
await r.zAdd("iot:recent", [{ score: Date.now(), value: JSON.stringify(event) }]);
|
||||||
await r.zRemRangeByRank("iot:recent", 0, -1001);
|
await r.zRemRangeByRank("iot:recent", 0, -1001);
|
||||||
} catch (e) { console.error("Redis error:", e.message); }
|
} catch (e) { console.error("Redis error:", e.message); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user