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

Allow TimedCacheProvider to take per object TTLs #30670

Closed
wezell opened this issue Nov 15, 2024 · 4 comments · Fixed by #30692 or #30935
Closed

Allow TimedCacheProvider to take per object TTLs #30670

wezell opened this issue Nov 15, 2024 · 4 comments · Fixed by #30692 or #30935

Comments

@wezell
Copy link
Contributor

wezell commented Nov 15, 2024

Parent Issue

No response

User Story

We have a timed cache provider that allows us to set a group TTL. When we want to build a cache that uses a per object TTL, we have to write some nasty code to work around this fact - and do things like have wrapper object and cleanup threads to remove stale entries. This is important for things like the blockdirectivecache and the Page cache, where each object has a specific TTL.

Acceptance Criteria

Allow networked caches to have a specific TTL per object.

Steps to Reproduce

  • Create a test HTML Page: /set-variable, and set its Cache TTL to zero.
  • Add a Contentlet of type Code Snippet to it, with the following code, which will store the foo entry to the Dynamic Cache for a period of 10 seconds:
<h1>Adding entry to the dot cache</h1>
<p>
    $dotcache.put("foo", "bar", 10)
</p>
  • Create another test HTML Page: /get-variable, and set its Cache TTL to zero as well.
  • Add a Contentlet of type Code Snippet to it, with the following code, which will read the value of the foo entry:
<h1>Retrieving cached entry</h1>
<p>
    Entry value = $dotcache.get("foo")
</p>
  • In the front-end, open up the /set-variable page.
  • In another tab, open up the /get-variable page. It must display the value of the foo variable: bar.
  • Now, wait for more than 10 second, and refresh the /get-variable page. You should get the Velocity code now instead of the variables value.
wezell added a commit that referenced this issue Nov 15, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 15, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 18, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 18, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
Copy link

github-actions bot commented Nov 18, 2024

wezell added a commit that referenced this issue Nov 18, 2024
… to our CaffineCache and really deprecates the timed cache provider.\n\nref:#30670
wezell added a commit that referenced this issue Nov 19, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 19, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
@wezell wezell moved this from New to Internal QA in dotCMS - Product Planning Nov 19, 2024
wezell added a commit that referenced this issue Nov 20, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 20, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 20, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 20, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 20, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
@wezell wezell linked a pull request Nov 21, 2024 that will close this issue
wezell added a commit that referenced this issue Nov 21, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
wezell added a commit that referenced this issue Nov 21, 2024
… to our CaffineCache and really deprecates the timed cache provider.

ref:#30670
@jcastro-dotcms jcastro-dotcms moved this from Internal QA to In Review in dotCMS - Product Planning Nov 22, 2024
@github-project-automation github-project-automation bot moved this from In Review to Internal QA in dotCMS - Product Planning Nov 22, 2024
@jcastro-dotcms jcastro-dotcms self-assigned this Nov 22, 2024
@jcastro-dotcms
Copy link
Contributor

INTERNAL QA: PASSED ✅

  • Docker Image: trunk_eaa0f2e

The CaffineCache is now using the DynamicTTLCache for providing per object TTL entries now, as expected. This is what the Settings > Maintenance > CACHE > Cache Stats looked like before the change -- notice the Timed Cache Provider Section there:

before

And this is what it looks like now:

after

@github-project-automation github-project-automation bot moved this from Internal QA to Current Sprint Backlog in dotCMS - Product Planning Nov 22, 2024
@jcastro-dotcms jcastro-dotcms moved this from Current Sprint Backlog to QA - Backlog in dotCMS - Product Planning Nov 22, 2024
@jcastro-dotcms jcastro-dotcms removed their assignment Nov 22, 2024
@josemejias11
Copy link
Contributor

Approved: Tested on trunk_68612b9, Docker, macOS 14.5, FF v126.0.1

@wezell
Copy link
Contributor Author

wezell commented Nov 27, 2024

This commit unified the TimedCacheProvider with the CaffineCache. In new installs, you will only see CaffineCache in your cache region list and if the region is configured to have an expiry time, it will show there.

@wezell wezell linked a pull request Dec 12, 2024 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Dec 13, 2024
#30670
The DynamicTTL does not call the stats collector when it instantiates
the Caffeine Cache. This adds the stats collector to the DynamicTTL
cache


![image](https://github.com/user-attachments/assets/832240c7-33b1-4af2-b4ba-e4ed9f3160bb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment