Reputation: 9171
I have a UserNamePasswordValidator and it hits a database to verify that the request is valid for the wcfclientcredentials.
I came to realize that I don't want to hit the database everytime I make a call.
What is the best way to cache the results?
ie if I already know username/pass is valid why check it over and over again?
Upvotes: 0
Views: 296
Reputation: 30097
Although I agree with mellamokb's comment but if you really wana do it...
I would go for Dictionary<UserName, SecureString>
Plus you will have to make sure that you update the dictionary in case of password change
Upvotes: 2
Reputation: 6637
You could cache the username/password
in a dictionary
with username
as the key and password
as the value.
Dictionary<string, string> userName_Pwd_Cache = new Dictionary<string, string>();
//caching username/password code
if(userName_Pwd_Cache.ContainsKey(userNameVar)) //let userNameVar is entered username
{
if(userName_Pwd_Cache[userNameVar] == passwordVar) //let passwordVar is entered passwords
{
//user authenticated
}
else
{
//authentication failed
}
}
Upvotes: 1