1
I have a static class and in it I have a method too static
. The method returns a value that is cached, however 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 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 builder:
static MeuHelper {
Key = User.Identity.GetUserName();
}
When I go thresh, I do it this way:
Logo with a user in the browser, and in another anonymous tab, soon with another user, however always prevails the value of the first user.
Editing:
The helper is for cache usage. It must have a key for each logged in user, for this reason I use the username, which is unique per user.
So the idea is to have the key in String
, to which the username
of the logged-in user.
What kind of
cache
?– Leonel Sanches da Silva
@The cache is redis, the same must have a unique key for each user session, so use the Username
– Rod