Skip to content

chore(cpp): Update update cache sample and add ttl option#16032

Open
bajajneha27 wants to merge 4 commits intogoogleapis:mainfrom
bajajneha27:update-cache-fix
Open

chore(cpp): Update update cache sample and add ttl option#16032
bajajneha27 wants to merge 4 commits intogoogleapis:mainfrom
bajajneha27:update-cache-fix

Conversation

@bajajneha27
Copy link
Contributor

No description provided.

@bajajneha27 bajajneha27 requested review from a team as code owners March 6, 2026 07:24
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Mar 6, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates a C++ sample for Google Cloud Storage Control to reflect a change in how AnywhereCache properties are modified. The sample now illustrates updating the Time To Live (TTL) for a cache, providing a more relevant example for cache management.

Highlights

  • Sample Update: Modified the UpdateAnywhereCache sample to demonstrate updating the ttl (Time To Live) field of an AnywhereCache instead of the admission_policy.
Changelog
  • google/cloud/storagecontrol/v2/samples/storage_control_anywhere_cache_samples.cc
    • Updated the UpdateAnywhereCache function to modify the ttl field instead of the admission_policy.
    • Changed the FieldMask to target the ttl field.
    • Set the ttl to 86400 seconds (1 day).
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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 updates the UpdateAnywhereCache sample to demonstrate updating the ttl field. My review found a critical compilation error due to incorrect operator usage on a stack-allocated object. I've provided a code suggestion to fix this. I also noted that a function parameter has become unused as a result of these changes and should be removed for code clarity.

field_mask.add_paths("ttl");
cache.set_name(cache_name);
cache.set_admission_policy(admission_policy);
cache->mutable_ttl()->set_seconds(86400);

Choose a reason for hiding this comment

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

critical

The cache object is a value type, not a pointer. You should use the . operator to access its members instead of ->. Using the arrow operator here will cause a compilation error.

Additionally, with this change, the admission_policy parameter is no longer used. Consider removing it from the function signature to avoid compiler warnings and improve code clarity.

    cache.mutable_ttl()->set_seconds(86400);

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.64%. Comparing base (eea3715) to head (11d9ab9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16032      +/-   ##
==========================================
- Coverage   92.64%   92.64%   -0.01%     
==========================================
  Files        2335     2335              
  Lines      214792   214792              
==========================================
- Hits       198986   198985       -1     
- Misses      15806    15807       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant