Skip to content

Fix caching conflicts #786

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

Merged
merged 18 commits into from
Apr 27, 2025
Merged

Fix caching conflicts #786

merged 18 commits into from
Apr 27, 2025

Conversation

sebastienros
Copy link
Owner

No description provided.

@lahma
Copy link
Collaborator

lahma commented Apr 25, 2025

This is interesting...

@hishamco
Copy link
Collaborator

How does it fix the caching conflicts?!!

@sebastienros
Copy link
Owner Author

I am iterating on this PR, I got a bug report, so first trying to see if I can repro without changes but different OSes, then I will add a test, and then the fix. Using this PR as the way to run on the oses I don't have (macos).

}

public bool TryGetTemplate(IFileInfo fileInfo, out IFluidTemplate template)
{
template = null;

if (_cache.TryGetValue(fileInfo.Name, out var cachedTemplate))
if (_cache.TryGetValue(fileInfo.PhysicalPath, out var cachedTemplate))
Copy link

Choose a reason for hiding this comment

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

Physical path can be null for in-memory filesystems. I think this will break people unless you require this at some other level.

Copy link

Choose a reason for hiding this comment

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

Can you use the path relative to the file provider root instead?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is problematic because IFileInfo is very limited here:

        //
        // Summary:
        //     The name of the file or directory, not including any path.
        string Name { get; }
        //
        // Summary:
        //     The path to the file, including the file name. Return null if the file is not
        //     directly accessible.
        string? PhysicalPath { get; }

@@ -23,33 +22,31 @@ public TemplateCache()
_cache = new(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
}

public bool TryGetTemplate(IFileInfo fileInfo, out IFluidTemplate template)
public bool TryGetTemplate(string subpath, DateTimeOffset lastModified, out IFluidTemplate template)
Copy link

Choose a reason for hiding this comment

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

👍

@sebastienros sebastienros merged commit 9fa20a5 into main Apr 27, 2025
3 checks passed
@sebastienros sebastienros deleted the sebros/fixcache branch April 27, 2025 22:52
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.

4 participants