• Raghav Muddur's avatar
    GETEX, GETDEL and SET PXAT/EXAT (#8327) · 0367a808
    Raghav Muddur authored
    This commit introduces two new command and two options for an existing command
    
    GETEX <key> [PERSIST][EX seconds][PX milliseconds] [EXAT seconds-timestamp]
    [PXAT milliseconds-timestamp]
    
    The getexCommand() function implements extended options and variants of the GET
    command. Unlike GET command this command is not read-only. Only one of the options
    can be used at a given time.
    
    1. PERSIST removes any TTL associated with the key.
    2. EX Set expiry TTL in seconds.
    3. PX Set expiry TTL in milliseconds.
    4. EXAT Same like EX instead of specifying the number of seconds representing the
        TTL (time to live), it takes an absolute Unix timestamp
    5. PXAT Same like PX instead of specifying the number of milliseconds representing the
        TTL (time to live), it takes an absolute Unix timestamp
    
    Command would return either the bulk string, error or nil.
    
    GETDEL <key>
    Would delete the key after getting.
    
    SET key value [NX] [XX] [KEEPTTL] [GET] [EX <seconds>] [PX <milliseconds>]
    [EXAT <seconds-timestamp>][PXAT <milliseconds-timestamp>]
    
    Two new options added here are EXAT and PXAT
    
    Key implementation notes
    - `SET` with `PX/EX/EXAT/PXAT` is always translated to `PXAT` in `AOF`. When relative time is
      specified (`PX/EX`), replication will always use `PX`.
    - `setexCommand` and `psetexCommand` would no longer need translation in `feedAppendOnlyFile`
      as they are modified to invoke `setGenericCommand ` with appropriate flags which will take care of
      correct AOF translation.
    - `GETEX` without any optional argument behaves like `GET`.
    - `GETEX` command is never propagated, It is either propagated as `PEXPIRE[AT], or PERSIST`.
    - `GETDEL` command is propagated as `DEL`
    - Combined the validation for `SET` and `GETEX` arguments. 
    - Test cases to validate AOF/Replication propagation
    0367a808
t_string.c 32.9 KB