Posted by: vsurajevs - Tuesday, 8 January 2013 11:39:03
Hello,
You guys very tried with developing cache for yaf forums so I spend full day vain tries to find workaround for this caching.
The problem is when I add new role to user, user cannot see forums from new role.
I tried to set all cache setting to 0 in Host Settings -> Cache
Also I used this method to clear cache after I add new role
[code=csharp]
public void ClearCaches()
{
DataSession.Instance.CurrentSession.CreateSQLQuery(@"EXEC yaf_activeaccess_reset").ExecuteUpdate();
YafContext.Current.Dispose();
foreach (var field in typeof(Constants.Cache).GetFields())
{
var rawConstantValue = field.GetRawConstantValue();
var key = rawConstantValue as String;
if (!String.IsNullOrEmpty(key))
YafContext.Current.Get().Remove(key);
}
YafContext.Current.Dispose();
YafContext.Current.Get().Clear();
YafContext.Current.Dispose();
DataSession.Instance.CommitTransaction();
DataSession.Instance.CurrentSession.CreateSQLQuery(@"DELETE FROM yaf_ActiveAccess").ExecuteUpdate();
DataSession.Instance.CommitTransaction();
}
[/code]
And no luck, best result what I achieved is using this method + manual application restart(and event that not always works)
I am using YAF 1.9.5.5
Please tell me how I can turn off this caching for ever ever ever!! Or how I can clean it with proper way so after adding new role to user this user could use this role immediately.
Thanks.
Posted by: vsurajevs - Tuesday, 8 January 2013 11:47:06
I am trying to add users to group simply adding user to role same as group name
[code=csharp] Roles.AddUserToRole(username, roleName);
var membershipUser = Membership.GetUser(username);
if (membershipUser != null)
{
Membership.UpdateUser(membershipUser);
cleanCache = true;
}[/code]
Posted by: tha_watcha - Tuesday, 8 January 2013 12:46:35
This is a known Bug in that Version, the easiest solution would be to upgrade to the latest Version. If not possible the only way is to modify the source in that Areas where the Roles are updated and execute the following code
[code=csharp;-1]LegacyDb.activeaccess_reset(); [/code]
Posted by: vsurajevs - Tuesday, 8 January 2013 13:50:15
Thank you for fast reply but I tried to do this when I clear cache
[code=csharp]DataSession.Instance.CurrentSession.CreateSQLQuery(@"EXEC yaf_activeaccess_reset").ExecuteUpdate();[/code]
I found that dbo.yaf_UserGroup updated after app restart and populated with new corresponding values so I inserted new user and group values in dbo.yaf_UserGroup when I add user to role than clear cache and dbo.yaf_ActiveAccess populated with correct values.