PragmaTwice commented on issue #595: URL: https://github.com/apache/incubator-kvrocks/issues/595#issuecomment-1131708536
Here are some initial ideas. To parse `SET key value [ NX | XX] [GET] [ EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]` ([ref](https://redis.io/commands/set/)): ``` #define CHECK(x) if(!x.ok()) return parse fail iter = parsing iterator(args...); CHECK(iter.pick_str(&key)); // insure the arg exists CHECK(iter.pick_str(&value)); if(iter.pick_eq("NX")) { set nx flag... } else if(iter.pick_eq("XX")) { set xx flag... } if(iter.pick_eq("GET")) { process... } if(iter.pick_eq("EX")) { CHECK(iter.pick_int(&seconds)); } else if(iter.pick_eq("PX")) { CHECK(iter.pick_int(&mseconds)); } else if(iter.pick_eq("EXAT")) { CHECK(iter.pick_int(&utseconds)); } else if(iter.pick_eq("PXAT")) { CHECK(iter.pick_int(&utmseconds)); } else if(iter.pick_eq("KEEPTTL")) { ... } CHECK(iter.end()); // remains no arg ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
