Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Caching Changes #941

Merged
merged 19 commits into from
Feb 3, 2013
Merged

Caching Changes #941

merged 19 commits into from
Feb 3, 2013

Conversation

grumpydev
Copy link
Member

Updated view and view location caching.

Removed the following:

  • The view location cache - caching is now performed by the view locator itself, using a custom cache
  • Removed (deprecated with an error) StaticConfiguration.DisabledCaches - replaced with settings in the StaticConfiguration.Caching class

Added the following:

  • StaticConfiguration.Caching.EnableRuntimeViewDiscovery - allows new views to be discovered at runtime (i.e. drop new views onto the disk and they'll be picked up)
  • StaticConfiguration.Caching.EnableRuntimeViewUpdates - allows views to be updated at runtime (i.e. edit a view template and it will be rebuilt)

Both these settings are set to true for Debug, and false for Release, although both can be set in the bootstrapper, or toggled from diagnostics. They are both disabled in release as we can assume our caches are immutable if they're off, which means we have no locks so faster performance (although the hit isn't massive). With the diagnostics toggling its easy to switch one or both on, update the files, then switch them back off again.

View updates currently not working with Spark because it seems to do its own caching and I couldn't figure out any way to fix it.

* Added a new IViewCache implementation, currently not default,
that checks if a view location result is stale or not.
* Added an "IsStale" virtual method to ViewLocationResult
which defaults to false.
* Added a new FileSystemViewLocationResult that checks the last
modified time and returns stale/not stale accordingly.
* Few other minor changes to fit in with the changes above.
Now DisableCaches is obsolete (and will throw an error), added
two new properties to StaticConfiguration.Caching to enable
and disable runtime view discovery and runtime view updating.
Now if runtime discovery is disabled we bypass the locking
completely - if there's no runtime discovery then our cache
can't change.
Spark uses its own caching/filesystem abstraction which
doesn't play nicely with anything else, so currently it just
grabs all the discovered views on startup and uses those. This
means that runtime view discovery is never going to be honored.

Runtime view updates also seem to be broken in Spark currently,
although I'm not 100% sure why as yet.

Test projects still not building at this point.
Runtime view discovery now seems to work ok.

Runtime view updating still broken though - seems to be a Spark
problem - I can see the updated view being sent to Spark from
NancyViewFolder.UpdateContents, and I can see the lats modified time
getting sent as changed, but Spark completely ignores the new content
and just serves the stale one.
@@ -5,34 +5,17 @@

public class ViewEngineStartupContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that this type is missing XML comments completely. I know it was not added in this PR, but if you have the energy to slap some on there then that would be cool, if not then we'll cover it in a ninjah commit later

All it was doing was passing in the extensions to the view engine.
And it got those extensions from that same view engine object.

Seemed kinda pointless :)
grumpydev added a commit that referenced this pull request Feb 3, 2013
@grumpydev grumpydev merged commit fb2503c into NancyFx:master Feb 3, 2013
@grumpydev grumpydev deleted the ViewCacheChanges branch April 7, 2014 09:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants