Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set template cache key #486

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SpeedyStuart
Copy link

This allows implementers to provide a delegate for generating the key that's used for template caching/retrieval. Therefore it allows templates to be cached based on something other than (just) their path + name.
Used with a custom file provider it allows different templates to be served based on arbitrary request properties - e.g. user-agent, cookie etc.
Possible solution for #470

@hishamco
Copy link
Collaborator

@SpeedyStuart, please fix the conflict

@@ -15,7 +15,6 @@ namespace Fluid.ViewEngine
public class FluidViewRenderer : IFluidViewRenderer
{
private static readonly char[] PathSeparators = { '/', '\\' };

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why?

/// <summary>
/// Represents the method that will generate a cache key for a supplied template path. Allows templates to be cached based on any external factor.
/// </summary>
public delegate string TemplateCacheKeyProviderDelegate(string path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if it's a good idea to have a delegate, I'm thinking of providing another API for caching or using IMemoryCache where the cache key could be provided by the user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants