This is a special thread-safe version of PlusAnonymousUserDataModel which allow multiple concurrent anonymous requests.
To use it, you have to estimate the number of concurrent anonymous users of your application. The pool of users with the given size will be created. For each anonymous recommendations request, a user has to be taken from the pool and returned back immediately afterwards.
If no more users are available in the pool, anonymous recommendations cannot be produced.
NReco.CF.Taste.Impl.Model PlusAnonymousUserDataModel
NReco.CF.Taste.Impl.Model PlusAnonymousConcurrentUserDataModel
Namespace: NReco.CF.Taste.Impl.Model
Assembly: NReco.Recommender (in NReco.Recommender.dll) Version: 1.0.0.0 (1.0.0.0)
The PlusAnonymousConcurrentUserDataModel type exposes the following members.
Name | Description | |
---|---|---|
PlusAnonymousConcurrentUserDataModel | Initializes a new instance of the PlusAnonymousConcurrentUserDataModel class |
int concurrentUsers = 100; IDataModel realModel = .. PlusAnonymousConcurrentUserDataModel plusModel = new PlusAnonymousConcurrentUserDataModel(realModel, concurrentUsers); IRecommender recommender = ...;
PlusAnonymousConcurrentUserDataModel plusModel = (PlusAnonymousConcurrentUserDataModel) recommender.GetDataModel(); // Take the next available anonymous user from the pool long anonymousUserID = plusModel.TakeAvailableUser(); IPreferenceArray tempPrefs = .. tempPrefs.SetUserID(0, anonymousUserID); tempPrefs.SetItemID(0, itemID); plusModel.SetTempPrefs(tempPrefs, anonymousUserID); // Produce recommendations recommender.Recommend(anonymousUserID, howMany); // It is very IMPORTANT to release user back to the pool plusModel.ReleaseUser(anonymousUserID);