YAFLogo

vsurajevs
  • vsurajevs
  • 50.2% (Neutral)
  • YAF Forumling Topic Starter
11 years ago
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

        
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<IDataCache>().Remove(key);
            }

            YafContext.Current.Dispose();
            
            YafContext.Current.Get<IDataCache>().Clear();

            YafContext.Current.Dispose();
           
            DataSession.Instance.CommitTransaction();

            DataSession.Instance.CurrentSession.CreateSQLQuery(@"DELETE FROM yaf_ActiveAccess").ExecuteUpdate();
            DataSession.Instance.CommitTransaction();
        }

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.

Sponsor
vsurajevs
  • vsurajevs
  • 50.2% (Neutral)
  • YAF Forumling Topic Starter
11 years ago
I am trying to add users to group simply adding user to role same as group name

                    Roles.AddUserToRole(username, roleName);
                    var membershipUser = Membership.GetUser(username);
                    if (membershipUser != null)
                    {
                        Membership.UpdateUser(membershipUser);
                        cleanCache = true;
                     }
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
11 years ago
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

LegacyDb.activeaccess_reset(); 
vsurajevs
  • vsurajevs
  • 50.2% (Neutral)
  • YAF Forumling Topic Starter
11 years ago
Thank you for fast reply but I tried to do this when I clear cache

DataSession.Instance.CurrentSession.CreateSQLQuery(@"EXEC yaf_activeaccess_reset").ExecuteUpdate();

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.