UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Q4JiO8Feph4wFctI+9ZGQSvRewR1NfbVajQfYaDycms=' 
WHERE 
  key_id = '409660771cc26a7c2642380d8239acfcfd119d6222a4020518060c046916b74c' 
  AND (
    token = 'Q4JiO8Feph4wFctI+9ZGQSvRewR1NfbVajQfYaDycms=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040