import { Command } from "./command.js";
/**
 * @see https://redis.io/commands/set
 */
export class SetCommand extends Command {
    constructor([key, value, opts], cmdOpts) {
        const command = ["set", key, value];
        if (opts) {
            if ("nx" in opts && opts.nx) {
                command.push("nx");
            }
            else if ("xx" in opts && opts.xx) {
                command.push("xx");
            }
            if ("get" in opts && opts.get) {
                command.push("get");
            }
            if ("ex" in opts && typeof opts.ex === "number") {
                command.push("ex", opts.ex);
            }
            else if ("px" in opts && typeof opts.px === "number") {
                command.push("px", opts.px);
            }
            else if ("exat" in opts && typeof opts.exat === "number") {
                command.push("exat", opts.exat);
            }
            else if ("pxat" in opts && typeof opts.pxat === "number") {
                command.push("pxat", opts.pxat);
            }
            else if ("keepTtl" in opts && opts.keepTtl) {
                command.push("keepTtl");
            }
        }
        super(command, cmdOpts);
    }
}
