UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'fg+RdiIutLz6o4acsklSCsWEzNanqy2tSokB8It1+iU=' 
WHERE 
  key_id = '40a9034decb291e1b1d321863053af53389d9853b749ff44cec8977fed6f7168' 
  AND (
    token = 'fg+RdiIutLz6o4acsklSCsWEzNanqy2tSokB8It1+iU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00016