support multiple user data keys

This commit is contained in:
Luke Pulverenti
2016-04-30 19:05:21 -04:00
parent 1f9d32afc5
commit 6330b13262
26 changed files with 219 additions and 268 deletions

View File

@@ -56,27 +56,30 @@ namespace MediaBrowser.Server.Implementations.Library
cancellationToken.ThrowIfCancellationRequested();
var key = item.GetUserDataKey();
var keys = item.GetUserDataKeys();
try
foreach (var key in keys)
{
await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false);
try
{
await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false);
var newValue = userData;
var newValue = userData;
// Once it succeeds, put it into the dictionary to make it available to everyone else
_userData.AddOrUpdate(GetCacheKey(userId, key), newValue, delegate { return newValue; });
}
catch (Exception ex)
{
_logger.ErrorException("Error saving user data", ex);
// Once it succeeds, put it into the dictionary to make it available to everyone else
_userData.AddOrUpdate(GetCacheKey(userId, key), newValue, delegate { return newValue; });
}
catch (Exception ex)
{
_logger.ErrorException("Error saving user data", ex);
throw;
throw;
}
}
EventHelper.FireEventIfNotNull(UserDataSaved, this, new UserDataSaveEventArgs
{
Key = key,
Keys = keys,
UserData = userData,
SaveReason = reason,
UserId = userId,