Skip to content

dataconnect: caching public api added#7716

Merged
dconeybe merged 4 commits intomainfrom
dconeybe/dataconnect/CacheAPI
Feb 6, 2026
Merged

dataconnect: caching public api added#7716
dconeybe merged 4 commits intomainfrom
dconeybe/dataconnect/CacheAPI

Conversation

@dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Feb 6, 2026

NOTE This PR was reverted in #7821 due to the implementation not being ready in time. The APIs were later added back by #7833.

This PR introduces into the firebase-dataconnect module public APIs for offline caching. The new CacheSettings and FetchPolicy mechanisms empower users to define caching strategies tailored to their specific needs.

Highlights

  • Offline Caching APIs: Introduced CacheSettings class and CacheSettings.Storage enum to configure local caching behavior for data operations.
  • DataConnectSettings Integration: DataConnectSettings now includes an optional cacheSettings property, allowing users to enable and configure caching for FirebaseDataConnect objects.
  • Query Fetch Policies: The QueryRef interface has been extended with a FetchPolicy enum and an overloaded execute method, providing explicit control over how queries retrieve data (e.g., PREFER_CACHE, CACHE_ONLY, SERVER_ONLY).
  • Data Source Indication: The QueryResult interface now includes a dataSource property, which indicates whether the retrieved data originated from the local CACHE or the remote SERVER.
  • Unit Test Coverage: New unit tests for CacheSettings and updated tests for DataConnectSettings and QueryResultImpl ensure the new caching functionalities are thoroughly validated.

@gemini-code-assist
Copy link
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
Contributor

github-actions bot commented Feb 6, 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.

@dconeybe
Copy link
Contributor Author

dconeybe commented Feb 6, 2026

/gemini review

Copy link
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 new public APIs for offline caching in the Data Connect SDK. The changes are extensive, adding new classes like CacheSettings, FetchPolicy, and DataSource, and modifying existing ones such as DataConnectSettings and QueryRef. While the new APIs are well-defined, the implementation appears to be incomplete. I've found a critical issue where a new public method is left with a TODO(), and another high-severity issue where a method's implementation contradicts its documented behavior. There's also an overload ambiguity that could break builds. I've provided suggestions to address these points. On a positive note, the unit tests have been diligently updated to cover the new additions.

@dconeybe
Copy link
Contributor Author

dconeybe commented Feb 6, 2026

/gemini summary

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request significantly enhances the firebase-dataconnect module by introducing comprehensive public APIs for offline caching. These changes provide developers with granular control over how data is fetched and stored locally, allowing for more robust and performant applications that can operate effectively even with intermittent network connectivity. The new CacheSettings and FetchPolicy mechanisms empower users to define caching strategies tailored to their specific needs.

Highlights

  • Offline Caching APIs: Introduced CacheSettings class and CacheSettings.Storage enum to configure local caching behavior for data operations.
  • DataConnectSettings Integration: DataConnectSettings now includes an optional cacheSettings property, allowing users to enable and configure caching for FirebaseDataConnect objects.
  • Query Fetch Policies: The QueryRef interface has been extended with a FetchPolicy enum and an overloaded execute method, providing explicit control over how queries retrieve data (e.g., PREFER_CACHE, CACHE_ONLY, SERVER_ONLY).
  • Data Source Indication: The QueryResult interface now includes a dataSource property, which indicates whether the retrieved data originated from the local CACHE or the remote SERVER.
  • Version Update: The firebase-dataconnect module version has been updated from 17.1.4 to 17.2.0.
  • Unit Test Coverage: New unit tests for CacheSettings and updated tests for DataConnectSettings and QueryResultImpl ensure the new caching functionalities are thoroughly validated.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • firebase-dataconnect/CHANGELOG.md
    • Added an entry for the new public APIs for offline caching.
  • firebase-dataconnect/api.txt
    • Introduced public final class CacheSettings with a public enum CacheSettings.Storage (MEMORY, PERSISTENT).
    • Added public final class CacheSettingsKt with a copy method.
    • Modified public final class DataConnectSettings to include a cacheSettings property and a new constructor.
    • Introduced public enum DataSource (CACHE, SERVER).
    • Updated public interface QueryRef with public enum QueryRef.FetchPolicy (CACHE_ONLY, PREFER_CACHE, SERVER_ONLY) and an overloaded execute method accepting a FetchPolicy.
    • Added public abstract com.google.firebase.dataconnect.DataSource dataSource property to public interface QueryResult.
  • firebase-dataconnect/gradle.properties
    • Updated the module version from 17.1.4 to 17.2.0.
  • firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/CacheSettings.kt
    • New file defining the CacheSettings class and its nested Storage enum, along with equals, hashCode, toString, and a copy extension function.
  • firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/DataConnectSettings.kt
    • Modified to incorporate cacheSettings as a constructor parameter and property.
    • Updated equals, hashCode, toString, and copy methods to account for the new cacheSettings property.
    • Added a secondary constructor for backward compatibility, marked with a TODO(BreakingChange).
  • firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/QueryRef.kt
    • Added FetchPolicy enum and an overloaded execute method to the QueryRef interface.
    • Added dataSource property to the QueryResult interface.
  • firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/QueryRefImpl.kt
    • Updated to implement the new execute(fetchPolicy) method, defaulting the parameterless execute() to FetchPolicy.PREFER_CACHE.
    • Modified QueryResultImpl constructor, equals, hashCode, and toString methods to include the dataSource property.
  • firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/QuerySubscriptionImpl.kt
    • Modified to pass DataSource.SERVER when creating QueryResultImpl instances within the subscription result.
  • firebase-dataconnect/src/test/kotlin/com/google/firebase/dataconnect/CacheSettingsUnitTest.kt
    • New unit test file for CacheSettings, covering default constructor, property assignment, toString, equals, hashCode, and copy behavior.
  • firebase-dataconnect/src/test/kotlin/com/google/firebase/dataconnect/DataConnectSettingsUnitTest.kt
    • Updated unit tests to include the new cacheSettings property in constructor tests, toString, equals, hashCode, and copy methods.
  • firebase-dataconnect/src/test/kotlin/com/google/firebase/dataconnect/core/QueryResultImplUnitTest.kt
    • Updated unit tests to include the new dataSource property in constructor tests, toString, equals, and hashCode methods.
  • firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/property/arbitrary/arbs.kt
    • Added arbitrary generation for CacheSettings.
    • Updated dataConnectSettings arbitrary generation to include cacheSettings.
Activity
  • gemini-code-assist[bot] provided initial guidance on using Gemini Code Assist.
  • github-actions[bot] posted guidelines for merging into the main branch.
  • dconeybe requested a Gemini review using /gemini review.
  • gemini-code-assist[bot] identified a critical issue: an unimplemented TODO() in a public API method.
  • gemini-code-assist[bot] highlighted a high-priority issue: overload resolution ambiguity for copy functions in DataConnectSettingsKt, suggesting removal of the older function.
  • gemini-code-assist[bot] noted a high-priority issue: the parameterless QueryRef.execute() method incorrectly fetches only from the server instead of using FetchPolicy.PREFER_CACHE, providing a code suggestion.
  • gemini-code-assist[bot] suggested a medium-priority improvement: converting CacheSettings to a data class for more idiomatic Kotlin and automatic generation of equals(), hashCode(), toString(), and copy() methods.
  • gemini-code-assist[bot] pointed out a low-priority issue: a formatting error and typo in CHANGELOG.md regarding the PR link.
  • gemini-code-assist[bot] identified a low-priority typo: the copyright year 2026 instead of 2024 in CacheSettings.kt.
  • gemini-code-assist[bot] identified another low-priority typo: the copyright year 2026 instead of 2024 in DataConnectSettingsUnitTest.kt.
  • dconeybe requested a Gemini summary using /gemini summary.

@dconeybe dconeybe marked this pull request as ready for review February 6, 2026 15:48
@dconeybe
Copy link
Contributor Author

dconeybe commented Feb 6, 2026

The "Metalava SemVer Check" failure can be ignored because it's complaining about methods being added to an interface, but the interface in question is specifically not intended for customers to subclass.

Copy link

@stephenarosaj stephenarosaj left a comment

Choose a reason for hiding this comment

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

LGTM

@dconeybe dconeybe merged commit 506716b into main Feb 6, 2026
42 of 43 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/CacheAPI branch February 6, 2026 17:34
@github-actions github-actions bot mentioned this pull request Feb 7, 2026
dconeybe added a commit that referenced this pull request Feb 18, 2026
…caching.

The implementation is not ready for release, so hiding it for now.
The plan is to re-introduce it in the next release.
dconeybe added a commit that referenced this pull request Feb 18, 2026
…caching.

The implementation is not ready for release, so hiding it for now.
The plan is to re-introduce it in the next release.
dconeybe added a commit that referenced this pull request Feb 18, 2026
…caching.

The implementation is not ready for release, so hiding it for now.
The plan is to re-introduce it in the next release.
@dconeybe
Copy link
Contributor Author

NOTE This PR was reverted in #7821 due to the implementation not being ready in time. The APIs will be added back once the implementation is ready.

@dconeybe
Copy link
Contributor Author

NOTE This PR was eventually unreverted by PR #7833

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants