UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'I0LH0+DL2LMmw4nMhVbPI5+nDD7RZj2jYsiSzNsMJzU=' 
WHERE 
  key_id = '590387ac165453b434e39f267a0ec0346680420d745934922ef941fb427c62b7' 
  AND (
    token = 'I0LH0+DL2LMmw4nMhVbPI5+nDD7RZj2jYsiSzNsMJzU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032