UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'G1zfAH8TSn5tnq9cndJThzhNAW88Kcr4PbETyRdSkX8='
WHERE
key_id = 'd5d23b1dd5b64561720d8ee7ad43d1221e6a61b9cb280058754d36824075eca1'
AND (
token = 'G1zfAH8TSn5tnq9cndJThzhNAW88Kcr4PbETyRdSkX8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)