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

Caching file system loader #116

Merged
merged 4 commits into from
Apr 17, 2023
Merged

Caching file system loader #116

merged 4 commits into from
Apr 17, 2023

Conversation

jg-rp
Copy link
Owner

@jg-rp jg-rp commented Apr 17, 2023

This pull request adds CachingFileSystemLoader, a template loader that handles its own LRU cache, instead of relying on the Environment cache. This should improve cache hits when rendering partial templates with {% render %} and {% include %}, and loading parent templates with template inheritance.

from liquid import CachingFileSystemLoader
from liquid import Environment

loader = CachingFileSystemLoader(search_path="templates/", cache_size=500)
env = Environment(loader=loader)
# ...

When initialising an Environment with a CachingFileSystemLoader, the environment cache is disabled and Environment arguments cache_size and auto_reload are ignored in favour of arguments to CachingFileSystemLoader.

@jg-rp jg-rp marked this pull request as ready for review April 17, 2023 10:29
@jg-rp jg-rp merged commit 7925446 into main Apr 17, 2023
@jg-rp jg-rp deleted the caching-loader branch April 17, 2023 10:29
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.

1 participant