Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Invalidate PageActionInvokerProvider cache when compilation cache expires #6438

Closed
wants to merge 1 commit into from

Conversation

pranavkm
Copy link
Contributor

Fixes #6428


IFilterMetadata[] filters;
if (!cache.Entries.TryGetValue(actionDescriptor, out cacheEntry))
if (!cache.Entries.TryGetValue(actionDescriptor, out PageActionInvokerCacheEntry cacheEntry))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The action descriptor(s) would still be valid if the compilation expires, but it's just the cached types that need to be invalidated. Thoughts \ concerns?


namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
{
public struct PageLoaderResult
Copy link
Member

Choose a reason for hiding this comment

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

I really don't like this approach. That's how we ended up with spaghetti in the view engine.

Copy link
Member

Choose a reason for hiding this comment

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

Should this just trigger a full rediscovery of all pages? What do you think is better?

I think the code you wrote is reasonable, but I don't like the approach of having two levels of caching. that can both get invalidated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do have a couple of options here:

a) Pump the compilation change tokens to an IActionDescriptorChangeProvider. This seems difficult though given the layering.
b) We could add change tokens _ViewImports for all files as part of the PageActionDescriptorChangeProvider. It's not super bad since already do file traversals as part of the PageADP. Given that there's so there's so much overlap in the actual number of distinct change tokens, this seems a bit unnecessary.
c) We could add change tokens for _ViewImports for a (non-existent) file at Pages root. All the other _ViewImports are already tracked by the **/*.cshtml.

Thoughts on the lot?

Copy link
Member

Choose a reason for hiding this comment

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

Can you explain c to me? Why isn't Pages/_ViewImports.cshtml included by **/*.cshtml?

Copy link
Member

Choose a reason for hiding this comment

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

I'd really prefer something like c.

Copy link
Contributor Author

@pranavkm pranavkm Jun 23, 2017

Choose a reason for hiding this comment

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

The issue here is the /_ViewImports.cshtml (the one above the /Pages directory. For (c) we say GetHierarchicalItems('${PagesRoot}/Index.cshtml") and watch all those files along with $"{PagesRoot}/**/*.cshtml"

Copy link
Member

Choose a reason for hiding this comment

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

OK, I like it. Let's do c.


IFilterMetadata[] filters;
if (!cache.Entries.TryGetValue(actionDescriptor, out cacheEntry))
if (!cache.Entries.TryGetValue(actionDescriptor, out PageActionInvokerCacheEntry cacheEntry))
Copy link
Member

Choose a reason for hiding this comment

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

out var

Copy link
Contributor Author

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

🆙 📅

@@ -43,6 +43,11 @@ public class ActionDescriptorCollectionProvider : IActionDescriptorCollectionPro

private IChangeToken GetCompositeChangeToken()
{
if (_actionDescriptorChangeProviders.Length == 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just seemed sensible not to have nested CompositeChangeTokens in the most common case.

.Select(item => item.Path)
.ToArray();

_searchPattern = rootDirectory + "/**/*.cshtml";
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this breathe a bit?

@pranavkm pranavkm closed this Jun 27, 2017
@pranavkm pranavkm deleted the prkrishn/6428 branch June 27, 2017 16:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants