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