UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'h+PUSn4DH0raaOxwQwRsefiHUe83zIQyDFNB3/G+P2k='
WHERE
key_id = 'ad1a735d5eeee4763e4cb08bf350734abd9eb6982faf242be0c19074d17af7f6'
AND (
token = 'h+PUSn4DH0raaOxwQwRsefiHUe83zIQyDFNB3/G+P2k='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)