UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Xk8iDJc4rP4qJj6cPVE33/JkReBkZpc0Ks7jsZPb5jo=' 
WHERE 
  key_id = '74787a31fe696343edbe10991b5678607cf26121ff3c5ee6fe20c51255badc7e' 
  AND (
    token = 'Xk8iDJc4rP4qJj6cPVE33/JkReBkZpc0Ks7jsZPb5jo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028