我正在尝试使用Nancy插件Nancy.LightningCache
根据docs,我应该可以轻松设置我的缓存,如下所示:
引导程序
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
this.EnableLightningCache(
container.Resolve<IRouteResolver>(),
ApplicationPipelines,
new[] {"id", "claim", "query", "take", "skip"});
}
路线
Get["/profile"] = _ =>
View["UserProfileView", Model].AsCacheable(DateTime.Now.AddSeconds(30));
当调用此路由时,我得到以下异常。
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:
'Nancy.Responses.Negotiation.Negotiator' does not contain a definition for 'AsCacheable'
有什么想法吗?
答案 0 :(得分:2)
我刚刚将这个https://gist.github.com/4191120一起攻击并且有效。全部使用0.13个nugets
答案 1 :(得分:0)
好的,明白了。
工作路线
return View["HomeView", (object)Model].AsCacheable(DateTime.Now.AddMinutes(1));
您可以看到我被迫将我的模型明确地转换为object
以满足AsCachable
扩展方法的签名。
问题仅出现在运行时,因为我的模型是ExpandoObject
,因此是dynamic
类型。