Skip to content

chore(cel): add support for custom caching key/time#157

Merged
yashmehrotra merged 1 commit into
mainfrom
sup-cache
May 21, 2026
Merged

chore(cel): add support for custom caching key/time#157
yashmehrotra merged 1 commit into
mainfrom
sup-cache

Conversation

@yashmehrotra
Copy link
Copy Markdown
Member

@yashmehrotra yashmehrotra commented May 19, 2026

Summary by CodeRabbit

  • New Features

    • Templates now support explicit cache key configuration and custom expiration times for improved cache management and optimization.
  • Tests

    • Enhanced test coverage for cache key behavior, expiration validation, and cross-data program reuse scenarios.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2b033be5-37cb-4d62-9543-03e35fb8c33e

📥 Commits

Reviewing files that changed from the base of the PR and between c8f67a2 and 613b482.

📒 Files selected for processing (2)
  • template.go
  • template_test.go

Walkthrough

This PR adds explicit caching control to the Template struct via new CacheKey and CacheTime fields, replacing the public CacheKey(env) method with internal key-selection helpers. CEL and Go template caches now store entries using the new cacheKey logic with configurable TTL instead of default cache behavior.

Changes

Template Caching Control

Layer / File(s) Summary
Cache configuration and key selection
template.go
Template struct adds optional CacheKey string and CacheTime duration fields. autoCacheKey(env) derives keys from template fields; cacheKey(env) returns explicit CacheKey if set, otherwise falls back to auto-derived key. IsCacheable logic updated.
CEL expression caching with TTL
template.go
CEL program cache lookup uses cacheKey(_environment); compilation via env.Program(ast) (no cel.Globals(data)); cached programs now stored with CacheTime TTL using Set(key, program, duration) instead of default insertion.
Go template caching with TTL
template.go
Go template cache lookup uses cacheKey(nil). Compiled templates stored via goTemplateCache.Set(cacheKey(nil), template, CacheTime) instead of default cache behavior.
Cache control and TTL validation tests
template_test.go
Imports time for TTL checks. TestCacheKeyConsistency updated to use cacheKey. New tests: TestExplicitCacheKey validates explicit key override and IsCacheable behavior; TestCacheTime validates no-expiration (-1), short TTL, and default TTL scenarios via GetWithExpiration; TestRunExpressionReusesProgramAcrossDifferentData confirms program cache reuse without data leakage across calls.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding support for custom caching control via CacheKey and CacheTime fields, with proper emphasis on the CEL expression caching improvements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sup-cache
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch sup-cache

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yashmehrotra yashmehrotra requested a review from moshloop May 19, 2026 11:47
@yashmehrotra
Copy link
Copy Markdown
Member Author

@moshloop Self merging this. Let me know if any changes were needed, will address them in a separate PR

@yashmehrotra yashmehrotra merged commit 43496a8 into main May 21, 2026
8 checks passed
@yashmehrotra yashmehrotra deleted the sup-cache branch May 21, 2026 02: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.

1 participant