通过可变参数缓存WCF服务

本文关键字:缓存 WCF 服务 参数 变参 | 更新日期: 2023-09-27 18:03:36

我有一个方法,这不是一个WCF操作,做身份验证检查

我如何缓存它的结果像60秒?并使用缓存的结果,如果存在我的操作方法,如果它不存在,执行方法来获得结果?

我想缓存基于用户名和密码的方法

public Autenticate (UserAccount useacc)
{
............
}  

 public class UserAccount
{
string username, passsword, domainname;
}

通过可变参数缓存WCF服务

你可以看看这个链接缓存

你可以这样使用这个类。

WCFCache.Current.Insert(username, useacc, DateTime.Now.AddMinutes(1));
//get an item from the cache
user = (UserAccount )WCFCache.Current[username];