逐步向服务添加缓存支持

时间:2012-10-29 02:40:34

标签: servicestack

我想在我的服务中使用内存缓存,但无法配置它。我已根据说明在global.asax注册了它。

以下是我的服务的外观:

public class CustomerSerivce: Service
{
    public CustomerResponse Any(Customer customer)
    {
        //code to connect to db here - this code is called regardless of cache entry
        return customer;
    }
}

我知道有this.RequestContext.ToOptimized或其他东西,但有些东西对我不起作用。

提前致谢。

2 个答案:

答案 0 :(得分:1)

你有声明: 使用ServiceStack.ServiceHost;

用于

的扩展方法
base.RequestContext.ToOptimizedResultUsingCache(...)

答案 1 :(得分:0)

一步一步是here。您还可以使用http 304 Not Modified handling查看here缺少的链接。

相关问题