UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'k4rU8Zqlx6IDd+GjaD1n9U0pj+yMrOEsn04q4D+qbDA=' 
WHERE 
  key_id = '8ff840ae033ecb5c9c3792ecbf8d605f2143b0bb001637625fac36cbe7354784' 
  AND (
    token = 'k4rU8Zqlx6IDd+GjaD1n9U0pj+yMrOEsn04q4D+qbDA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027