The website I'm building has a heavily extended user model. The requirement is to have a single page where admins (who are windows authenticated users) can see the profiles of all the users. Regular users (who are FBA authenticated) must also be able to view/edit their own profile from the "My Sites" profile.
The solution I've come up with involves using the User Profile service, and programatically retrieving the profiles to present to the admins. The profiles can then be edited with code similar to the following:
SPSite site = new SPSite(SPContext.Current.Site.ID);
SPServiceContext serviceCtx = SPServiceContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(serviceCtx);
UserProfile profile = profileManager.GetUserProfile(userId);
//Update the profile
profile["someProperty"].Value = "new value";
However, it takes about 20 seconds for the change to be seen in the admin's view. Repeating the call and inspecting the profile shows the old values. The value is immediately persisted to the DB and a user viewing their profile sees the change instantly.
It seems the data is being cached and I suspect this is the role of the User Profile Service Application Proxy but this behaviour seems wrong?
Is there a better way, or at least a way to bypass/invalidate the cache? Your help is MUCH appreciated.