UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'EiPytulAKNN+nfImk776+L9jC+379AhpNLiIJx+c6XU=' 
WHERE 
  key_id = '46ded3d372991d19b385b3a5131d1d602079777e11751cbfcfa591e266d3d3d1' 
  AND (
    token = 'EiPytulAKNN+nfImk776+L9jC+379AhpNLiIJx+c6XU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028