I have a static class and I also have a method with static
. The method returns a value that is cached, however this Key
, it has the dynamic value:
key = User.Identity.GetUserName();
public static class MeuHelper {
public static string Get {
get {
return cache.Get(key);
}
}
}
How could I declare this property KEY
?
I've tried the following statements
public static string Key = User.Identity.GetUserName();
public static string Key {
get {
return User.Identity.GetUserName();
}
}
And even:
public static string Key {Get;set;}
In the constructor:
static MeuHelper {
Key = User.Identity.GetUserName();
}
When I go debug , I do this:
Soon with a user in the browser, and another anonymous flip, soon with another user, however, the value of the first user always prevails.
Issue:
The helper is for cache usage. The same must have a key for each user logged in, so I use the username, which is unique per user.
Then the idea is to have key in String
, which will always return the username
of the logged in user.