@@ -1110,6 +1110,45 @@ def getset(key, value)
11101110 end
11111111 end
11121112
1113+ # Get the value of key and delete the key. This command is similar to GET,
1114+ # except for the fact that it also deletes the key on success.
1115+ #
1116+ # @param [String] key
1117+ # @return [String] the old value stored in the key, or `nil` if the key
1118+ # did not exist
1119+ def getdel ( key )
1120+ synchronize do |client |
1121+ client . call ( [ :getdel , key ] )
1122+ end
1123+ end
1124+
1125+ # Get the value of key and optionally set its expiration. GETEX is similar to
1126+ # GET, but is a write command with additional options. When no options are
1127+ # provided, GETEX behaves like GET.
1128+ #
1129+ # @param [String] key
1130+ # @param [Hash] options
1131+ # - `:ex => Integer`: Set the specified expire time, in seconds.
1132+ # - `:px => Integer`: Set the specified expire time, in milliseconds.
1133+ # - `:exat => true`: Set the specified Unix time at which the key will
1134+ # expire, in seconds.
1135+ # - `:pxat => true`: Set the specified Unix time at which the key will
1136+ # expire, in milliseconds.
1137+ # - `:persist => true`: Remove the time to live associated with the key.
1138+ # @return [String] The value of key, or nil when key does not exist.
1139+ def getex ( key , ex : nil , px : nil , exat : nil , pxat : nil , persist : false )
1140+ args = [ :getex , key ]
1141+ args << "EX" << ex if ex
1142+ args << "PX" << px if px
1143+ args << "EXAT" << exat if exat
1144+ args << "PXAT" << pxat if pxat
1145+ args << "PERSIST" if persist
1146+
1147+ synchronize do |client |
1148+ client . call ( args )
1149+ end
1150+ end
1151+
11131152 # Get the length of the value stored in a key.
11141153 #
11151154 # @param [String] key
0 commit comments