fix: timestamp as score for zadd

This commit is contained in:
2026-07-22 09:09:27 +04:00
parent 9b5201332e
commit 03fefc07fd
+1 -1
View File
@@ -47,7 +47,7 @@ async function store(event) {
value: event.value, unit: event.unit, location: event.location, timestamp: event.timestamp,
}));
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);
} catch (e) { console.error("Redis error:", e.message); }