I am trying to use the Nancy addin Nancy.LightningCache
According to the docs I should be able to set up my caching easily, like this:
Bootstrapper
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
this.EnableLightningCache(
container.Resolve<IRouteResolver>(),
ApplicationPipelines,
new[] {"id", "claim", "query", "take", "skip"});
}
Route
Get["/profile"] = _ =>
View["UserProfileView", Model].AsCacheable(DateTime.Now.AddSeconds(30));
When this route is called I get the following exception.
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:
'Nancy.Responses.Negotiation.Negotiator' does not contain a definition for 'AsCacheable'
Any ideas?
OK, got it.
Working Route
You can see that I have been forced to explicitly cast my Model to an
objectin order to satisfy the signature of theAsCachableextension method.The problem only shows up at runtime because my Model is an
ExpandoObjectand so adynamictype.