Is my cache being shared by how many pages do I have per session?

0

Good morning guys, so I created a class to handle the cache, but to open the site in the same browser but with different users, one takes the cache of the other. how can I restrict by "session" it? Thanks!

Methods:

    public T GetKeyValue<T>(string key)
    {
        var cache = HttpContext.Current.Cache[key];
        if (cache != null)
            return (T)cache;

        return default(T);
    }

    public void SetKeyValue<T>(T obj, string key)
    {
        if (string.IsNullOrEmpty(key) || obj == null)
            return;

        HttpRuntime.Cache.Insert(key, obj,
                        null,
                        DateTime.Now.AddHours(1),
                        Cache.NoSlidingExpiration 
                        );
    }

UPDATE

When you open one more tab, this method overwrites the "user" so all open websites take colors, styles, user settings that you have ... my doubt is, how to do this by user caching in a correct, clean, and so on. because I concatenei but still sometimes breaks some little thing

   public void Authenticate(string user)
    {
        if (CanAuthenticated(user))
        {
            this.User = user;
            this.Password = "password";
            var villaUser = this.SPAccessLogin.LogIn();
            this.VillaSiteUser = villaUser;
            this.IsAuthenticated = true;
        }
    }
    
asked by anonymous 24.11.2016 / 13:10

0 answers