From cb82710daf9aa8ba564462ab083e3a4b2a0096fa Mon Sep 17 00:00:00 2001 From: John Sully Date: Sun, 1 Mar 2020 19:17:58 -0500 Subject: [PATCH 1/2] Rename cron command to KEYDB.CRON and add help Former-commit-id: 3eb847e28f6df45528dcebc6761290ff60248e78 --- src/help.h | 8 +++++++- src/server.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/help.h b/src/help.h index 34f4e77c7..d3870d490 100644 --- a/src/help.h +++ b/src/help.h @@ -1168,7 +1168,13 @@ struct commandHelp { "destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]", "Add multiple sorted sets and store the resulting sorted set in a new key", 4, - "2.0.0" } + "2.0.0" }, + { "KEYDB.CRON", + "name [single/repeat] [optional: start] delay script numkeys [key N] [arg N]", + "Run a specified script after start + delay, optionally repeating every delay interval. The job may be cancelled by deleting the key associated with the job (name parameter)", + 10, + "6.5.2" + } }; #endif diff --git a/src/server.cpp b/src/server.cpp index 837b1c38e..311f2bffa 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1026,7 +1026,7 @@ struct redisCommand redisCommandTable[] = { "read-only fast noprop", 0,NULL,0,0,0,0,0,0}, - {"cron",cronCommand,-5, + {"keydb.cron",cronCommand,-5, "write use-memory", 0,NULL,1,1,1,0,0,0}, }; From aab740a2e35330f2ff6d5deb55b67ce20d070656 Mon Sep 17 00:00:00 2001 From: John Sully Date: Sun, 1 Mar 2020 21:42:01 -0500 Subject: [PATCH 2/2] Update tests to reflect new CRON name (keydb.cron) Former-commit-id: 83f585e30ab9d37408c79b74e2536664325a051f --- tests/unit/cron.tcl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/unit/cron.tcl b/tests/unit/cron.tcl index 554df9328..dddf78255 100644 --- a/tests/unit/cron.tcl +++ b/tests/unit/cron.tcl @@ -1,47 +1,47 @@ start_server {tags {"CRON"}} { - test {cron singleshot past tense} { + test {keydb.cron singleshot past tense} { r flushall - r cron testjob single 0 1 {redis.call("incr", "testkey")} 1 testkey + r keydb.cron testjob single 0 1 {redis.call("incr", "testkey")} 1 testkey after 300 assert_equal 1 [r get testkey] assert_equal 0 [r exists testjob] } - test {cron repeat past tense next exec is in the future} { + test {keydb.cron repeat past tense next exec is in the future} { r flushall - r cron testjob repeat 0 1000000 {redis.call("incr", "testkey")} 1 testkey + r keydb.cron testjob repeat 0 1000000 {redis.call("incr", "testkey")} 1 testkey after 300 assert_equal 1 [r get testkey] assert_equal 1 [r exists testjob] r del testjob } - test {cron repeat works} { + test {keydb.cron repeat works} { r flushall - r cron testjob repeat 0 600 {redis.call("incr","testkey")} + r keydb.cron testjob repeat 0 600 {redis.call("incr","testkey")} after 1000 assert_equal 2 [r get testkey] } - test {cron overwrite works} { + test {keydb.cron overwrite works} { r flushall - r cron testjob single 500 {redis.call("set","testkey","a")} 1 testkey - r cron testjob single 500 {redis.call("set","anotherkey","b")} 1 anotherkey + r keydb.cron testjob single 500 {redis.call("set","testkey","a")} 1 testkey + r keydb.cron testjob single 500 {redis.call("set","anotherkey","b")} 1 anotherkey after 1000 assert_equal 0 [r exists testkey] assert_equal b [r get anotherkey] } - test {cron delete key stops job} { + test {keydb.cron delete key stops job} { r flushall - r cron testjob single 500 {redis.call("set","testkey","a")} + r keydb.cron testjob single 500 {redis.call("set","testkey","a")} r del testjob after 1000 assert_equal 0 [r exists testkey] } - test {cron zero interval rejected} { - catch {r cron testjob single 0 0 {redis.call("incr","testkey")} 1 testkey} e + test {keydb.cron zero interval rejected} { + catch {r keydb.cron testjob single 0 0 {redis.call("incr","testkey")} 1 testkey} e assert_match {ERR*} $e } }