Add datetime rounding for @ApiCache to improve cache hits#1
Merged
maikschneider merged 10 commits intomainfrom Mar 26, 2026
Merged
Add datetime rounding for @ApiCache to improve cache hits#1maikschneider merged 10 commits intomainfrom
maikschneider merged 10 commits intomainfrom
Conversation
Create new @ApiCacheRoundDatetime annotation that rounds datetime filter parameter values to configurable precisions (minute, hour, day, year) before cache key generation, improving cache hit rates for datetime-based API queries. Supports floor and ceil rounding directions. Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/afd7d73b-38c3-43b9-935d-91d703ae3505
…rison Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/afd7d73b-38c3-43b9-935d-91d703ae3505
…THOD The annotation now targets properties and methods instead of the class, allowing multiple annotations per entity. Each annotation configures rounding for a single datetime parameter with precision, direction, and optional parameterName override. Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/6c2d48c6-acbe-4974-8a01-e9da35707089
…ution Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/cdf5ee1d-dd32-4fc6-b42a-8b5cb4d3dde7
…roperty When @ApiCacheRoundDatetime is placed on a method with @VirtualProperty and @SerializedName, the serialized name is automatically used as the query parameter name. Priority: explicit parameterName > @SerializedName > @VirtualProperty name > PHP property/method name. Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/cdf5ee1d-dd32-4fc6-b42a-8b5cb4d3dde7
Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/19222277-263f-4f38-ba7c-2f1487cae4ee
…composer.lock Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/27fcd744-689a-471d-9a6d-9a0847da91a3
…rName, support filter variants Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/34f3bbca-56d0-435b-86ee-fa960cb7aac0
…ed parameterName Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/34f3bbca-56d0-435b-86ee-fa960cb7aac0
…e-pass iteration Co-authored-by: maikschneider <696865+maikschneider@users.noreply.github.com> Agent-Logs-Url: https://github.com/xima-media/t3api_cache/sessions/34f3bbca-56d0-435b-86ee-fa960cb7aac0
Copilot created this pull request from a session on behalf of
maikschneider
March 26, 2026 11:13
View session
maikschneider
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
@ApiCacheRoundDatetimeannotation for datetime filter cache key normalizationWhen using datetime filters with
@ApiCache, clients typically pass the current timestamp, which changes on every request and prevents cache hits. The new@ApiCacheRoundDatetimeclass-level annotation rounds datetime filter parameter values to a configurable precision (minute, hour, day, or year) before cache key generation, so that requests within the same time window produce identical cache keys.Features
@ApiCacheRoundDatetimeannotation — placed on the entity class alongside@ApiCacheminute,hour(default),day, oryearfloor(default, round down) orceil(round up)parameterName(e.g."date") applies rounding todate,date[lt],date[gte], etc.Example
Requests with
?date=2025-03-26T09:47:12+00:00and?date=2025-03-26T09:12:45+00:00both round to2025-03-26T09:00:00+00:00, producing the same cache key.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.