Skip to content

dataconnect: maxAge implemented for offline caching#7848

Merged
dconeybe merged 18 commits intomainfrom
dconeybe/dataconnect/MaxAge
Feb 27, 2026
Merged

dataconnect: maxAge implemented for offline caching#7848
dconeybe merged 18 commits intomainfrom
dconeybe/dataconnect/MaxAge

Conversation

@dconeybe
Copy link
Copy Markdown
Contributor

@dconeybe dconeybe commented Feb 25, 2026

This PR introduces support for maxAge in firebase-dataconnect, allowing developers to specify the maximum age of a cached response that is acceptable.

Highlights

  • maxAge Support: The CacheSettings class now includes a maxAge property to control the freshness of cached data.
  • Stale Cache Handling: The DataConnectGrpcRPCs class now checks if a cached result is stale based on maxAge and fetches from the server if it is.
Changelog
  • CHANGELOG.md
    • Added a changelog entry for the new maxAge feature.
  • CacheSettings.kt
    • Added a maxAge property to the CacheSettings class.
  • DataConnectGrpcRPCs.kt
    • Updated executeQuery to check if a cached result is stale based on maxAge.
    • Updated insertQueryResult to store the maxAge with the cached result.
  • DataConnectCacheDatabase.kt
    • Updated getQueryResult to check if a cached result is stale based on maxAge.
    • Updated insertQueryResult to store the maxAge with the cached result.
  • DataConnectGrpcRPCsTest.kt
    • Added property-based tests for the new maxAge feature.
  • IntWithEvenNumDigitsDistribution.kt
    • Added a new test utility for generating random Int values with an even distribution of the number of digits.
  • LongWithEvenNumDigitsDistribution.kt
    • Added a new test utility for generating random Long values with an even distribution of the number of digits.
  • testutil/property/arbitrary/arbs.kt
    • Added a new test utility for generating random protobuf Duration objects.
  • RangeExtsUnitTest.kt
    • Added unit tests for the new IntRange.intersect and LongRange.intersect extension functions.
  • IntWithEvenNumDigitsDistributionUnitTest.kt
    • Added unit tests for the new intWithEvenNumDigitsDistribution test utility.
  • LongWithEvenNumDigitsDistributionUnitTest.kt
    • Added unit tests for the new longWithEvenNumDigitsDistribution test utility.
  • testutil/property/arbitrary/arbsUnitTest.kt
    • Added unit tests for the new maxAgeArb test utility.
  • testutil/property/arbitrary/protoUnitTest.kt
    • Added unit tests for the new duration test utility.
  • testutil/property/arbitrary/tuplesUnitTest.kt
    • Added unit tests for the new tuple test utilities.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 25, 2026

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@google-oss-bot

This comment was marked as outdated.

1 similar comment
@google-oss-bot

This comment was marked as outdated.

@dconeybe
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a maxAge parameter to the CacheSettings class, enabling offline caching to respect the maximum age of cached query results. The changes include modifications to the CHANGELOG.md, api.txt, CacheSettings.kt, DataConnectGrpcRPCs.kt, FirebaseDataConnectImpl.kt, DataConnectCacheDatabase.kt, DataConnectCacheDatabaseMigrator.kt, sdk.proto, CacheSettingsUnitTest.kt, DataConnectGrpcRPCsUnitTest.kt, and several test utility files. The code review comment suggests removing the redundant normalizedDuration variable in DataConnectCacheDatabase.kt.

@dconeybe dconeybe marked this pull request as ready for review February 26, 2026 22:27
@dconeybe dconeybe merged commit 185b4ce into main Feb 27, 2026
174 of 178 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/MaxAge branch February 27, 2026 18:40
@github-actions github-actions bot mentioned this pull request Feb 28, 2026
@firebase firebase locked and limited conversation to collaborators Mar 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants