UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'OiR2v0ewm5pcK2F1mBkxR4S7sLnm0N+RXIx9GerLIAk=' 
WHERE 
  key_id = '3204f6d4662a31311355b97093fa72e2f413fe8b109fe44c3d30118ee3576ef5' 
  AND (
    token = 'OiR2v0ewm5pcK2F1mBkxR4S7sLnm0N+RXIx9GerLIAk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029