Conversation
…instead of throwing [skip actions]
Using Gemini Code AssistThe 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
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 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. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request modifies the behavior of the CACHE_ONLY fetch policy to return stale data instead of throwing an exception, which is a significant and useful change. The implementation involves refactoring the caching logic into a new executeQueryAgainstCache function in DataConnectGrpcRPCs and enhancing getQueryResult in DataConnectCacheDatabase to handle stale data more flexibly. The changes are accompanied by a comprehensive set of new integration and unit tests that cover the new behavior thoroughly. The code quality is high, with good use of helper functions in tests to reduce duplication. I have one minor suggestion to enhance test coverage in a property-based test.
📝 PRs merging into main branchOur 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. |
This PR modifies dataconnect's offline caching behavior for queries using the
CACHE_ONLYfetch policy in thefirebase-dataconnectmodule. Previously, requesting data withCACHE_ONLYwould throw an exception if the cached data was older than the configuredmaxAge. With this change,CACHE_ONLYwill return the stale data instead of throwing. An exception is now only thrown when the data is entirely absent from the cache.Highlights
CACHE_ONLYBehavior Change: Queries executed with theCACHE_ONLYfetch policy will now return stale cached data instead of throwing an exception if the data has expired according tomaxAge.DataConnectCacheDatabase.getQueryResult()to accept astaleResultparameter, allowing the caller to specify whether stale data should be surfaced asFound,Stale, orNotFound.CACHE_ONLY,PREFER_CACHE, default) against differentmaxAgeconfigurations (passed, not passed, zero, infinite).Changelog
maxAgecombinations.fetchPolicyparameter optional ingetString.staleResultbased on the fetch policy.staleResultparameter togetQueryResult()to control stale data handling.getQueryResult()with the newstaleResultparameter.