[ 
https://issues.apache.org/jira/browse/FREEMARKER-220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17746129#comment-17746129
 ] 

Dániel Dékány commented on FREEMARKER-220:
------------------------------------------

I have checked it, and it works fine. This is what I used:
{code:java}
    public static void main(String[] args) throws TemplateModelException, 
IOException, InterruptedException {
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_33);
        cfg.setTemplateLoader(new FileTemplateLoader(new File(
                "c:\\Users\\me\\adhoc\\freemarker-template-loader-test\\")));
        cfg.setTemplateUpdateDelayMilliseconds(10000);
        System.out.println(cfg.getTemplateUpdateDelayMilliseconds());
        int counter = 0;
        while (true) {
            counter++;
            System.out.println("-- getTemplate #" + counter + ": --");
            cfg.getTemplate("test.ftlh");
            Thread.sleep
            (1000);
        }
    }
{code}
and it outputs this (with FreeMarker debug-level logging to the stdout):
{code:java}
10000
-- getTemplate #1: --
22:56:01.344 DEBUG [freemarker.cache] f.c.TemplateCache:412 - Couldn't find 
template in cache for "test.ftlh"("hu_HU", UTF-8, parsed); will try to load it.
22:56:01.347 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test_hu_HU.ftlh"): Not found
22:56:01.348 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test_hu.ftlh"): Not found
22:56:01.349 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test.ftlh"): Found
22:56:01.350 DEBUG [freemarker.cache] f.c.TemplateCache:436 - Loading template 
for "test.ftlh"("hu_HU", UTF-8, parsed) from 
"C:\\Users\\me\\adhoc\\freemarker-template-loader-test\\test.ftlh"
-- getTemplate #2: --
22:56:02.424 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #3: --
22:56:03.426 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #4: --
22:56:04.438 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #5: --
22:56:05.438 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #6: --
22:56:06.442 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #7: --
22:56:07.443 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #8: --
22:56:08.447 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #9: --
22:56:09.461 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #10: --
22:56:10.464 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #11: --
22:56:11.479 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test_hu_HU.ftlh"): Not found
22:56:11.480 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test_hu.ftlh"): Not found
22:56:11.481 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test.ftlh"): Found
22:56:11.482 DEBUG [freemarker.cache] f.c.TemplateCache:393 - 
"test.ftlh"("hu_HU", UTF-8, parsed): using cached since 
C:\Users\me\adhoc\freemarker-template-loader-test\test.ftlh hasn't changed.
-- getTemplate #12: --
22:56:12.491 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #13: --
22:56:13.491 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #14: --
22:56:14.495 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #15: --
22:56:15.509 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #16: --
22:56:16.524 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #17: --
22:56:17.532 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #18: --
22:56:18.545 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #19: --
22:56:19.557 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #20: --
22:56:20.569 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #21: --
22:56:21.583 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test_hu_HU.ftlh"): Not found
22:56:21.583 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test_hu.ftlh"): Not found
22:56:21.584 DEBUG [freemarker.cache] f.c.TemplateCache:786 - 
TemplateLoader.findTemplateSource("test.ftlh"): Found
22:56:21.584 DEBUG [freemarker.cache] f.c.TemplateCache:393 - 
"test.ftlh"("hu_HU", UTF-8, parsed): using cached since 
C:\Users\me\adhoc\freemarker-template-loader-test\test.ftlh hasn't changed.
-- getTemplate #22: --
22:56:22.593 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
-- getTemplate #23: --
22:56:23.602 DEBUG [freemarker.cache] f.c.TemplateCache:352 - 
"test.ftlh"("hu_HU", UTF-8, parsed) cached copy not yet stale; using cached.
[etc.]
{code}

> Can't change the setting template_update_delay above 1000ms
> -----------------------------------------------------------
>
>                 Key: FREEMARKER-220
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-220
>             Project: Apache Freemarker
>          Issue Type: Bug
>    Affects Versions: 2.3.31, 2.3.32
>         Environment: macOS Catalina Version 10.15.7 (19H15), Eclipse Java / 
> WebObjects
>            Reporter: Necati ÜNLÜ
>            Priority: Major
>
> We're currently developing a web application that dynamically generates pages 
> using FreeMarker. In an effort to improve processing performance, we 
> discovered the template caching feature and its associated delay setting, 
> which FreeMarker uses to evaluate whether a cached template is stale or not.
> In our processing logs, we noticed that template lookup consumes 
> approximately 30% of FreeMarker's processing time. Our custom loaders' 
> overridden methods are called for each template, even if they're the same, 
> which led us to believe there was an issue with caching.
> To test this, we manually set a delay and saw the same template being 
> searched multiple times when the delay was exceeded, confirming our 
> suspicion. We attempted to increase the template update delay to better suit 
> our needs, but regardless of the method used
> {code:java}
> configuration.setTemplateUpdateDelay(3600);
> configuration.setTemplateUpdateDelayMilliseconds(3600000);
> configuration.setSetting(Configuration.TEMPLATE_UPDATE_DELAY_KEY, "1 
> h");{code}
> the delay value remains stubbornly at 1000ms. It's worth mentioning that we 
> were only able to change this value to a number less than 1000ms, even when 
> the value was negative.
> This is odd, as the default value stated in the FreeMarker documentation is 
> 5000ms. Whether we checked using
> {code:java}
> configuration.getTemplateUpdateDelayMilliseconds();
> configuration.getSetting(Configuration.TEMPLATE_UPDATE_DELAY_KEY);{code}
> or even via Eclipse's debug mode, the result is consistently 1000ms, even 
> when the check is made immediately after the delay setting instruction.
> Despite our thorough search, we found no other interaction with this delay 
> elsewhere in our code. We also confirmed that the page templates are indeed 
> being added to the cache via debugger.
> In light of the above, we're reporting this potential bug, as we are unable 
> to adjust the template update delay setting above 1000ms. We look forward to 
> your assistance in resolving this issue.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to