|
261 | 261 | """ |
262 | 262 |
|
263 | 263 | # KEYS = { scheduled_zset_key, task_data_key } |
264 | | -# ARGV = { score, member, serialized_task_data } |
| 264 | +# ARGV = { score, member } |
| 265 | +# score is used both as the new ZSET score and as the new scheduled_at value. |
265 | 266 | UPDATE_SCHEDULED_TIME = """ |
266 | 267 | local score = redis.call('zscore', KEYS[1], ARGV[2]) |
267 | 268 | if score then |
268 | 269 | redis.call('zadd', KEYS[1], ARGV[1], ARGV[2]) |
269 | | - redis.call('set', KEYS[2], ARGV[3]) |
| 270 | + local data = cjson.decode(redis.call('get', KEYS[2])) |
| 271 | + data['scheduled_at'] = tonumber(ARGV[1]) |
| 272 | + redis.call('set', KEYS[2], cjson.encode(data)) |
270 | 273 | return 1 |
271 | 274 | else |
272 | 275 | return 0 |
@@ -587,16 +590,15 @@ def update_scheduled_time( |
587 | 590 | task_data_key: str, |
588 | 591 | score: float, |
589 | 592 | member: str, |
590 | | - serialized_task_data: str, |
591 | 593 | ) -> bool: |
592 | 594 | """ |
593 | | - Atomically updates a task's scheduled time in the ZSET and its _data |
594 | | - blob. Returns True if the task was found and updated, False if the task |
595 | | - was not present in the ZSET. |
| 595 | + Atomically updates a task's scheduled time in the ZSET and patches |
| 596 | + scheduled_at in the _data blob. Returns True if the task was found and |
| 597 | + updated, False if the task was not present in the ZSET. |
596 | 598 | """ |
597 | 599 | result = self._update_scheduled_time( |
598 | 600 | keys=[scheduled_zset_key, task_data_key], |
599 | | - args=[score, member, serialized_task_data], |
| 601 | + args=[score, member], |
600 | 602 | ) |
601 | 603 | return bool(result) |
602 | 604 |
|
|
0 commit comments