Skip to content

feat(storagecontrol): add Rapid Cache samples - #2343

Merged
bshaffer merged 5 commits into
mainfrom
storagecontrol-rapid-cache-samples-php
Nov 6, 2026
Merged

bshaffer merged 5 commits into
mainfrom
storagecontrol-rapid-cache-samples-php

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Adds Storage Control samples for Rapid Cache, plus a test:

  • create_rapid_cache.php (storage_control_create_rapid_cache): creates a rapid-cache-ultra cache in a zone and waits for the LRO to finish. The server assigns the cache name.
  • get_rapid_cache.php (storage_control_get_rapid_cache)
  • list_rapid_caches.php (storage_control_list_rapid_caches)
  • update_rapid_cache.php (storage_control_update_rapid_cache): sets the TTL with update mask ttl.
  • disable_rapid_cache.php (storage_control_disable_rapid_cache): starts the disable LRO and prints the operation name. It does not wait, because the operation runs for more than an hour.
  • test/rapidCacheTest.php: runs the whole lifecycle on a regional HNS + UBLA bucket, then polls get until the state is disabled. Bucket deletion fails with 409 for a long time after a cache is disabled, so cleanup is best-effort: it retries briefly, then logs the name of any bucket it left behind.
  • Raises google/cloud-storage-control to ^1.12, which has the RapidCache API.

b/482946642

Validation: php-cs-fixer and PHPStan both pass. The live test has not been run yet. Rapid Cache RPCs work only over gRPC, and the authoring environment has no ext-grpc. CI does have it.

[Generated-by: AI]


Update: aligned with googleapis/google-cloud-java#14529

The samples now follow the reference integration test (ITRapidCacheTest). Where this section conflicts with the notes above, this section is current.

  • Create: sets the cache name explicitly to projects/_/buckets/{bucket}/rapidCaches/{zone} (the backend requires the cache ID to equal the zone), with cache_type rapid-cache-ultra and ttl 86400s (24h). It also prints the state.
  • Create / update: wait for the LRO with no time limit (totalPollTimeoutMillis 0). Before, they used the 5-minute client default. If the operation fails, they print the error.
  • Get: also prints the cache type.
  • Disable: now waits for the LRO. An optional $timeoutMillis argument (default 0 = no limit) bounds the wait. If the wait times out, the sample prints that the operation is still running. If the operation fails, it prints the error.
  • Test:
    • Uses cache ID = zone, and waits 20s after creating the bucket.
    • Asserts the cache name, State: running, the cache type, list membership, and TTL 172800s after update.
    • Disables with a 10-minute bound. If the operation isn't done by then, it asserts that get shows State: disabled and does not fail.
    • Teardown disables the cache if the test didn't (errors are ignored), then deletes the bucket on a best-effort basis and logs any leftover bucket.
  • Region tags are unchanged.

Validation: php -l, php-cs-fixer (repo config), and PHPStan (repo config) all pass. The live test was not run locally because ext-grpc is missing in the authoring environment.

[Generated-by: AI]

Adds create, get, list, update and disable Rapid Cache samples for Storage Control, with tests. Bumps google/cloud-storage-control to ^1.12. b/482946642

[Generated-by: AI]
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 2, 2026
@sahusneha2004 sahusneha2004 added ai-generated Generated by AI storage-sample-architect Generated by storage-sample-architect skill labels Nov 2, 2026

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

Copy link
Copy Markdown

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 google/cloud-storage-control dependency and introduces new PHP code samples for managing the lifecycle of Rapid Cache instances, including creation, retrieval, listing, updating, and disabling. It also adds a comprehensive integration test suite. The feedback highlights a PSR-1/PSR-12 style guide violation regarding the test class name casing, and suggests guarding against a potential null pointer dereference in the update sample when retrieving the TTL from the response.

Comment thread storagecontrol/test/rapidCacheTest.php Resolved
…ation test

Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642

[Generated-by: AI]
- Rename rapidCacheTest to RapidCacheTest (PSR-1 StudlyCaps).
- Guard TTL output with hasTtl() in update_rapid_cache.

[Generated-by: AI]
…lify test teardown

- create_rapid_cache: set only name, zone and cache type (rapid-cache-ultra),
  matching create_anywhere_cache; TTL is left to update_rapid_cache.
- create_rapid_cache: use $rapidCacheId, consistent with get/update/disable.
- RapidCacheTest: rename $cacheDisabled to $cacheActive, flatten
  tearDownAfterClass into disableCacheQuietly/deleteBucketQuietly helpers,
  and use a constant for the updated TTL.

[Generated-by: AI]
@sahusneha2004
sahusneha2004 marked this pull request as ready for review November 6, 2026 12:03
@sahusneha2004
sahusneha2004 requested review from a team as code owners November 6, 2026 12:03
@snippet-bot

snippet-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@bshaffer
bshaffer merged commit f19d196 into main Nov 6, 2026
12 checks passed
@bshaffer
bshaffer deleted the storagecontrol-rapid-cache-samples-php branch November 6, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Generated by AI samples Issues that are directly related to samples. storage-sample-architect Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants