UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'brTO7dIWQI4wtBa4zdBMJno+UBysPAf3gfoQZaAfOhM=' 
WHERE 
  key_id = 'd40b1e345bb041aec818aad642451c404ecabe172495dbe833dfd0d7a362defd' 
  AND (
    token = 'brTO7dIWQI4wtBa4zdBMJno+UBysPAf3gfoQZaAfOhM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035