From 485ce4b6cd788e79a1f5e25f03cfc0bac951d4e6 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Wed, 22 Jan 2025 17:13:51 +0000 Subject: [PATCH 01/26] docs(memorystore): added valkey practical sourcecode samples --- .../valkey/caching/samples/.mvn/jvm.config | 0 .../valkey/caching/samples/.mvn/maven.config | 0 memorystore/valkey/caching/samples/REAMDE.md | 31 ++++++ memorystore/valkey/caching/samples/pom.xml | 100 ++++++++++++++++++ .../java/samples/MemorystoreDeleteItem.java | 40 +++++++ .../java/samples/MemorystoreReadItem.java | 37 +++++++ .../main/java/samples/MemorystoreTTLItem.java | 63 +++++++++++ .../java/samples/MemorystoreWriteItem.java | 33 ++++++ 8 files changed, 304 insertions(+) create mode 100644 memorystore/valkey/caching/samples/.mvn/jvm.config create mode 100644 memorystore/valkey/caching/samples/.mvn/maven.config create mode 100644 memorystore/valkey/caching/samples/REAMDE.md create mode 100644 memorystore/valkey/caching/samples/pom.xml create mode 100644 memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java create mode 100644 memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java create mode 100644 memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java create mode 100644 memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java diff --git a/memorystore/valkey/caching/samples/.mvn/jvm.config b/memorystore/valkey/caching/samples/.mvn/jvm.config new file mode 100644 index 00000000000..e69de29bb2d diff --git a/memorystore/valkey/caching/samples/.mvn/maven.config b/memorystore/valkey/caching/samples/.mvn/maven.config new file mode 100644 index 00000000000..e69de29bb2d diff --git a/memorystore/valkey/caching/samples/REAMDE.md b/memorystore/valkey/caching/samples/REAMDE.md new file mode 100644 index 00000000000..bd7de626b47 --- /dev/null +++ b/memorystore/valkey/caching/samples/REAMDE.md @@ -0,0 +1,31 @@ +# Caching Samples + +This folder contains a samples in form of stand-alone snippets that demonstrate useful scenarios. + +## Prerequiites + +Ensure the following setup is in place. + +### Java + +You must have java installed locally on your machinee. Run `java --version` to check if this is available. + +### MemoryStore for Valkey Instance + +A working instance of memorystore for valkey must be available. You can run the [Valkey CLI](https://valkey.io/topics/cli/) for a local instance, or create an instance through the [GCP Platform](https://console.cloud.google.com/memorystore/valkey/instances?). + +## Running the sample code + +Each example contains instructions on any prerequiite configuration. + +## Compile the app through Maven (optional) + +```bash +mvn compile +``` + +## Run the sample code + +```bash +mvn exec:java -Dexec.mainClass=MemorystoreTTLItem //Replace the main class as needed +``` diff --git a/memorystore/valkey/caching/samples/pom.xml b/memorystore/valkey/caching/samples/pom.xml new file mode 100644 index 00000000000..9dcd811532d --- /dev/null +++ b/memorystore/valkey/caching/samples/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + + samples + samples + 1.0-SNAPSHOT + + Google Cloud Memorystore Sample + http://www.example.com + + + UTF-8 + 17 + + + + + + org.junit + junit-bom + 5.11.0 + pom + import + + + + + + + + redis.clients + jedis + 4.3.1 + + + + + com.google.cloud + google-cloud-core + 2.16.0 + + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-params + test + + + + + + + + maven-clean-plugin + 3.4.0 + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.13.0 + + + maven-surefire-plugin + 3.3.0 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.2 + + + maven-deploy-plugin + 3.1.2 + + + maven-site-plugin + 3.12.1 + + + maven-project-info-reports-plugin + 3.6.1 + + + + + diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java new file mode 100644 index 00000000000..2cae544b432 --- /dev/null +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java @@ -0,0 +1,40 @@ +/** + * This code snippet is part of a tutorial on how to use Memorystore for Valkey. + * + *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code + * snippet. + * + *

Prerequisites: 1. A running Memorystore for Valkey instance in Google Cloud. 2. Your client + * must run in the same VPC network as the Memorystore instance. + * + *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" with + * the key to be deleted from the cache. + */ +import redis.clients.jedis.Jedis; + +public class MemorystoreDeleteItem { + + public static void main(String[] args) { + /** Connect to your Memorystore for Valkey instance */ + Jedis jedis = new Jedis("127.0.0.1", 6379); + + /** Replace with the item ID to delete from the cache */ + String itemId = "foo"; + + /** Delete the item from the cache */ + Long result = jedis.del(itemId); + + /** Check if any items have been successfully deleted */ + if (result > 0) { + System.out.println("Successfully deleted item with ID: " + itemId); + } + + /* Print out that no item has been found for deletion */ + if (result == 0) { + System.out.println("No item found with ID: " + itemId); + } + + /** Close the Redis connection */ + jedis.close(); + } +} diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java new file mode 100644 index 00000000000..434a214cfac --- /dev/null +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java @@ -0,0 +1,37 @@ +/** + * This code snippet demonstrates how to read an item from Google Cloud Memorystore for Redis. + * + *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code + * snippet. + * + *

Prerequisites: 1. A running Memorystore for Redis instance in Google Cloud. 2. An item already + * cached in the Redis instance with a known ID. + * + *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" with + * an actual cached item ID. + */ +import redis.clients.jedis.Jedis; + +public class MemorystoreReadItem { + + public static void main(String[] args) { + /** Connect to your Memorystore for Valkey instance */ + Jedis jedis = new Jedis("127.0.0.1", 6379); + + /** Replace with an actual cached item ID */ + String itemId = "foo"; + + /** Read the cached item */ + String cachedItem = jedis.get(itemId); + + /* If found, print out the cached item */ + if (cachedItem != null) { + System.out.println("Cached item: " + cachedItem); + } + + /** If no item found, print a message */ + if (cachedItem == null) { + System.out.println("No cached item found with ID: " + itemId); + } + } +} diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java new file mode 100644 index 00000000000..72667067424 --- /dev/null +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java @@ -0,0 +1,63 @@ +/** + * This code snippet is part of a tutorial on how to use Memorystore for Valkey. + * + *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code + * snippet. + * + *

Prerequisites: 1. A running Memorystore for Valkey instance in Google Cloud. 2. Your client + * must run in the same VPC network as the Memorystore instance. + * + *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" and + * "ITEM_VALUE" with the key and value to cache. + */ +import redis.clients.jedis.Jedis; + +public class MemorystoreTTLItem { + + public static void main(String[] args) throws InterruptedException { + /** Connect to your Memorystore for Valkey instance */ + Jedis jedis = new Jedis("127.0.0.1", 6379); + + /** Replace with the item ID and value to cache */ + String itemId = "foo"; + String itemValue = "bar"; + + /** Set a TTL of 10 seconds during entry creation */ + int ttlSeconds = 10; + + /** Create a new cached item with a TTL value */ + jedis.setex(itemId, ttlSeconds, itemValue); + + /** Print out the cached item details */ + System.out.println( + "Item cached with ID: " + itemId + " and value: " + itemValue + " for " + ttlSeconds + "s"); + + /** Wait for 5 seconds */ + System.out.println("Waiting for 5 seconds..."); + Thread.sleep(5000); + + /** Retrieve the remaining TTL */ + Long remainingTTL = jedis.ttl(itemId); + + /** Find the cached item, and print out the remanining expiry */ + String cachedItem = jedis.get(itemId); + + /** Print out the item id with remaining TTL value */ + System.out.println("Remaining TTL for item " + itemId + ": " + remainingTTL + "s"); + + /** Wait for another 6 seconds to demonstrate TTL expiry */ + System.out.println("Waiting for 6 seconds for expiry..."); + Thread.sleep(6000); + + /** Retrieve the remaining TTL or check item existence */ + remainingTTL = jedis.ttl(itemId); + + /** If TTL is less than 0, print a message indicating expiration */ + if (remainingTTL < 0) { + System.out.println("Item with ID " + itemId + " has expired and is no longer available."); + } + + /** Close the Redis connection */ + jedis.close(); + } +} diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java new file mode 100644 index 00000000000..094f63d514e --- /dev/null +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java @@ -0,0 +1,33 @@ +/** + * This code snippet is part of a tutorial on how to use Memorystore for Redis. + * + *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code + * snippet. + * + *

Prerequisites: 1. A running Memorystore for Redis instance in Google Cloud. + * + *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" and + * "ITEM_VALUE" with the key and value to be cached. + */ +import redis.clients.jedis.Jedis; + +public class MemorystoreWriteItem { + + public static void main(String[] args) { + /** Connect to the Memorystore Redis instance */ + Jedis jedis = new Jedis("127.0.0.1", 6379); + + /** Replace with the item ID and value to cache */ + String itemId = "foo"; + String itemValue = "bar"; + + /** Write the item to the cache */ + jedis.set(itemId, itemValue); + + /** Print out the cached result */ + System.out.println("Item cached with ID: " + itemId + " and value: " + itemValue); + + /** Close the connection */ + jedis.close(); + } +} From 6166c60ed3ca0d3dd93c564c19708ae278750e0d Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 10:10:04 +0000 Subject: [PATCH 02/26] docs(memorystore): added appropriate Apache 2 headers --- memorystore/valkey/caching/samples/pom.xml | 16 ++++++++++++++++ .../main/java/samples/MemorystoreDeleteItem.java | 16 ++++++++++++++++ .../main/java/samples/MemorystoreReadItem.java | 16 ++++++++++++++++ .../main/java/samples/MemorystoreTTLItem.java | 16 ++++++++++++++++ .../main/java/samples/MemorystoreWriteItem.java | 16 ++++++++++++++++ 5 files changed, 80 insertions(+) diff --git a/memorystore/valkey/caching/samples/pom.xml b/memorystore/valkey/caching/samples/pom.xml index 9dcd811532d..8e730344fca 100644 --- a/memorystore/valkey/caching/samples/pom.xml +++ b/memorystore/valkey/caching/samples/pom.xml @@ -1,3 +1,19 @@ + + diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java index 2cae544b432..c68baa8be49 100644 --- a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This code snippet is part of a tutorial on how to use Memorystore for Valkey. * diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java index 434a214cfac..041bfc89c5f 100644 --- a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This code snippet demonstrates how to read an item from Google Cloud Memorystore for Redis. * diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java index 72667067424..613a64e2051 100644 --- a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This code snippet is part of a tutorial on how to use Memorystore for Valkey. * diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java index 094f63d514e..c46f4bc4a14 100644 --- a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This code snippet is part of a tutorial on how to use Memorystore for Redis. * From bab6fcb89afdec1df2991b932cebef1a31e49aed Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 10:10:50 +0000 Subject: [PATCH 03/26] docs(memorystore): chnaged folder name from samples to snippets --- memorystore/valkey/caching/{samples => snippets}/.mvn/jvm.config | 0 .../valkey/caching/{samples => snippets}/.mvn/maven.config | 0 memorystore/valkey/caching/{samples => snippets}/REAMDE.md | 0 memorystore/valkey/caching/{samples => snippets}/pom.xml | 0 .../src/main/java/samples/MemorystoreDeleteItem.java | 0 .../src/main/java/samples/MemorystoreReadItem.java | 0 .../src/main/java/samples/MemorystoreTTLItem.java | 0 .../src/main/java/samples/MemorystoreWriteItem.java | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename memorystore/valkey/caching/{samples => snippets}/.mvn/jvm.config (100%) rename memorystore/valkey/caching/{samples => snippets}/.mvn/maven.config (100%) rename memorystore/valkey/caching/{samples => snippets}/REAMDE.md (100%) rename memorystore/valkey/caching/{samples => snippets}/pom.xml (100%) rename memorystore/valkey/caching/{samples => snippets}/src/main/java/samples/MemorystoreDeleteItem.java (100%) rename memorystore/valkey/caching/{samples => snippets}/src/main/java/samples/MemorystoreReadItem.java (100%) rename memorystore/valkey/caching/{samples => snippets}/src/main/java/samples/MemorystoreTTLItem.java (100%) rename memorystore/valkey/caching/{samples => snippets}/src/main/java/samples/MemorystoreWriteItem.java (100%) diff --git a/memorystore/valkey/caching/samples/.mvn/jvm.config b/memorystore/valkey/caching/snippets/.mvn/jvm.config similarity index 100% rename from memorystore/valkey/caching/samples/.mvn/jvm.config rename to memorystore/valkey/caching/snippets/.mvn/jvm.config diff --git a/memorystore/valkey/caching/samples/.mvn/maven.config b/memorystore/valkey/caching/snippets/.mvn/maven.config similarity index 100% rename from memorystore/valkey/caching/samples/.mvn/maven.config rename to memorystore/valkey/caching/snippets/.mvn/maven.config diff --git a/memorystore/valkey/caching/samples/REAMDE.md b/memorystore/valkey/caching/snippets/REAMDE.md similarity index 100% rename from memorystore/valkey/caching/samples/REAMDE.md rename to memorystore/valkey/caching/snippets/REAMDE.md diff --git a/memorystore/valkey/caching/samples/pom.xml b/memorystore/valkey/caching/snippets/pom.xml similarity index 100% rename from memorystore/valkey/caching/samples/pom.xml rename to memorystore/valkey/caching/snippets/pom.xml diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java similarity index 100% rename from memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreDeleteItem.java rename to memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java similarity index 100% rename from memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreReadItem.java rename to memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java similarity index 100% rename from memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreTTLItem.java rename to memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java diff --git a/memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java similarity index 100% rename from memorystore/valkey/caching/samples/src/main/java/samples/MemorystoreWriteItem.java rename to memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java From 9ec47bac150ee03364eb416dfa732c6c3bceb384 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 11:42:23 +0000 Subject: [PATCH 04/26] chore(memorystore): updated caching snippet pom metadata --- memorystore/valkey/caching/snippets/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memorystore/valkey/caching/snippets/pom.xml b/memorystore/valkey/caching/snippets/pom.xml index 8e730344fca..5702744ae7b 100644 --- a/memorystore/valkey/caching/snippets/pom.xml +++ b/memorystore/valkey/caching/snippets/pom.xml @@ -19,8 +19,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - samples - samples + com.example.memorystore + caching 1.0-SNAPSHOT Google Cloud Memorystore Sample From f539fbfca003f4d5da02fbf208e118638564fb87 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 11:45:25 +0000 Subject: [PATCH 05/26] chore(memorystore): feedback updates on the readme --- memorystore/valkey/caching/snippets/REAMDE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/memorystore/valkey/caching/snippets/REAMDE.md b/memorystore/valkey/caching/snippets/REAMDE.md index bd7de626b47..18add020a92 100644 --- a/memorystore/valkey/caching/snippets/REAMDE.md +++ b/memorystore/valkey/caching/snippets/REAMDE.md @@ -10,9 +10,9 @@ Ensure the following setup is in place. You must have java installed locally on your machinee. Run `java --version` to check if this is available. -### MemoryStore for Valkey Instance +### Memorystore for Valkey Instance -A working instance of memorystore for valkey must be available. You can run the [Valkey CLI](https://valkey.io/topics/cli/) for a local instance, or create an instance through the [GCP Platform](https://console.cloud.google.com/memorystore/valkey/instances?). +A working instance of Memorystore for Valkey must be available. You can run the [Valkey CLI](https://valkey.io/topics/cli/) for a local instance, or create an instance through the [GCP Platform](https://console.cloud.google.com/memorystore/valkey/instances?). ## Running the sample code @@ -27,5 +27,5 @@ mvn compile ## Run the sample code ```bash -mvn exec:java -Dexec.mainClass=MemorystoreTTLItem //Replace the main class as needed +mvn exec:java -Dexec.mainClass=MemorystoreTTLItem #Replace the main class as needed ``` From 05d02e6591ea8a2e12253df613e2eaee0f034cd0 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 11:48:00 +0000 Subject: [PATCH 06/26] chore(memorystore): moved configurable variables into the class file, updated pre-requisite descriptions --- .../java/samples/MemorystoreDeleteItem.java | 20 +++++++++++----- .../java/samples/MemorystoreReadItem.java | 19 ++++++++++----- .../main/java/samples/MemorystoreTTLItem.java | 23 +++++++++++++------ .../java/samples/MemorystoreWriteItem.java | 21 ++++++++++++----- 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java index c68baa8be49..632cec813f9 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java @@ -20,8 +20,8 @@ *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code * snippet. * - *

Prerequisites: 1. A running Memorystore for Valkey instance in Google Cloud. 2. Your client - * must run in the same VPC network as the Memorystore instance. + *

Prerequisites: 1. A running Memorystore for Valkey instance. 2. An exisiting item to delete + * from the Memrystore cache. * *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" with * the key to be deleted from the cache. @@ -30,12 +30,20 @@ public class MemorystoreDeleteItem { + /** Configure the Memorystore instance id */ + private static final String instanceId = "INSTANCE_ID"; + + /** Configure the Memorystore port, if not the default port */ + private static final int port = 6379; + + /** Configure the id of the item to delete from Memorystore */ + private static final String itemId = "ITEM_ID"; + + /* Run the code snippet */ public static void main(String[] args) { - /** Connect to your Memorystore for Valkey instance */ - Jedis jedis = new Jedis("127.0.0.1", 6379); - /** Replace with the item ID to delete from the cache */ - String itemId = "foo"; + /** Connect to your Memorystore for Valkey instance */ + Jedis jedis = new Jedis(instanceId, port); /** Delete the item from the cache */ Long result = jedis.del(itemId); diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java index 041bfc89c5f..c716a0068cd 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java @@ -20,8 +20,8 @@ *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code * snippet. * - *

Prerequisites: 1. A running Memorystore for Redis instance in Google Cloud. 2. An item already - * cached in the Redis instance with a known ID. + *

Prerequisites: 1. A running Memorystore for Valkey instance. 2. An exisiting item to read from + * the Memrystore cache. * *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" with * an actual cached item ID. @@ -30,12 +30,19 @@ public class MemorystoreReadItem { + /** Configure the Memorystore instance id */ + private static final String INSTANCE_ID = "INSTANCE_ID"; + + /** Configure the Memorystore port, if not the default port */ + private static final int PORT = 6379; + + /** Configure the id of the item to read from Memorystore */ + private static final String ITEM_ID = "ITEM_ID"; + + /* Run the code snippet */ public static void main(String[] args) { /** Connect to your Memorystore for Valkey instance */ - Jedis jedis = new Jedis("127.0.0.1", 6379); - - /** Replace with an actual cached item ID */ - String itemId = "foo"; + Jedis jedis = new Jedis(instanceId, port); /** Read the cached item */ String cachedItem = jedis.get(itemId); diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java index 613a64e2051..ce96d92be6d 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java @@ -20,8 +20,7 @@ *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code * snippet. * - *

Prerequisites: 1. A running Memorystore for Valkey instance in Google Cloud. 2. Your client - * must run in the same VPC network as the Memorystore instance. + *

Prerequisites: 1. A running Memorystore for Valkey instance. * *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" and * "ITEM_VALUE" with the key and value to cache. @@ -30,13 +29,23 @@ public class MemorystoreTTLItem { + /** Configure the Memorystore instance id */ + private static final String instanceId = "INSTANCE_ID"; + + /** Configure the Memorystore port, if not the default port */ + private static final int port = 6379; + + /** Configure the id of the item to read/write from Memorystore */ + private static final String itemId = "ITEM_ID"; + + /** Configure the value of the item to read/write from Memorystore */ + private static final String itemValue = "ITEM_VALUE"; + + /* Run the code snippet */ public static void main(String[] args) throws InterruptedException { - /** Connect to your Memorystore for Valkey instance */ - Jedis jedis = new Jedis("127.0.0.1", 6379); - /** Replace with the item ID and value to cache */ - String itemId = "foo"; - String itemValue = "bar"; + /** Connect to your Memorystore for Valkey instance */ + Jedis jedis = new Jedis(instanceId, port); /** Set a TTL of 10 seconds during entry creation */ int ttlSeconds = 10; diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index c46f4bc4a14..a21aacddb76 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -20,7 +20,7 @@ *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code * snippet. * - *

Prerequisites: 1. A running Memorystore for Redis instance in Google Cloud. + *

Prerequisites: 1. A running Memorystore for Valkey instance. * *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" and * "ITEM_VALUE" with the key and value to be cached. @@ -29,13 +29,22 @@ public class MemorystoreWriteItem { + /** Configure the Memorystore instance id */ + private static final String instanceId = "INSTANCE_ID"; + + /** Configure the Memorystore port, if not the default port */ + private static final int port = 6379; + + /** Configure the id of the item to write to Memorystore */ + private static final String itemId = "ITEM_ID"; + + /** Configure the id of the item to write to Memorystore */ + private static final String itemValue = "ITEM_VALUE"; + + /* Run the code snippet */ public static void main(String[] args) { /** Connect to the Memorystore Redis instance */ - Jedis jedis = new Jedis("127.0.0.1", 6379); - - /** Replace with the item ID and value to cache */ - String itemId = "foo"; - String itemValue = "bar"; + Jedis jedis = new Jedis(instanceId, port); /** Write the item to the cache */ jedis.set(itemId, itemValue); From 0b14b5898736940abcd40e4b55ebba43d3fd178b Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 12:15:19 +0000 Subject: [PATCH 07/26] fix(memorystore): fixed caching POM error --- memorystore/valkey/caching/snippets/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/memorystore/valkey/caching/snippets/pom.xml b/memorystore/valkey/caching/snippets/pom.xml index 5702744ae7b..35263730dc2 100644 --- a/memorystore/valkey/caching/snippets/pom.xml +++ b/memorystore/valkey/caching/snippets/pom.xml @@ -1,3 +1,5 @@ + + - 4.0.0 From e6c53d6ea4eeefbd8ec8d5ecbb8970ce6f65589a Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 12:16:17 +0000 Subject: [PATCH 08/26] docs(caching): updated read item snippet variables --- .../src/main/java/samples/MemorystoreReadItem.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java index c716a0068cd..c9819bbdd76 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java @@ -31,16 +31,17 @@ public class MemorystoreReadItem { /** Configure the Memorystore instance id */ - private static final String INSTANCE_ID = "INSTANCE_ID"; + private static final String instanceId = "INSTANCE_ID"; /** Configure the Memorystore port, if not the default port */ - private static final int PORT = 6379; + private static final int port = 6379; /** Configure the id of the item to read from Memorystore */ - private static final String ITEM_ID = "ITEM_ID"; + private static final String itemId = "ITEM_ID"; /* Run the code snippet */ public static void main(String[] args) { + /** Connect to your Memorystore for Valkey instance */ Jedis jedis = new Jedis(instanceId, port); From eed23133f510ed893b1b71793cdc51da37c5ee86 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 12:19:22 +0000 Subject: [PATCH 09/26] memorystore(caching): minor comment update --- .../snippets/src/main/java/samples/MemorystoreTTLItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java index ce96d92be6d..8106dfa07c9 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java @@ -23,7 +23,7 @@ *

Prerequisites: 1. A running Memorystore for Valkey instance. * *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" and - * "ITEM_VALUE" with the key and value to cache. + * "ITEM_VALUE" with the key and value of the item to cache. */ import redis.clients.jedis.Jedis; From 99728be0a2950071c464db332e693c417c16d8ca Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 14:50:29 +0000 Subject: [PATCH 10/26] fix(memorystore): added try-with-resources to all snippets --- .../java/samples/MemorystoreDeleteItem.java | 28 ++++---- .../java/samples/MemorystoreReadItem.java | 25 +++++--- .../main/java/samples/MemorystoreTTLItem.java | 64 +++++++++++-------- .../java/samples/MemorystoreWriteItem.java | 23 ++++--- 4 files changed, 79 insertions(+), 61 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java index 632cec813f9..9793a377824 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java @@ -27,6 +27,7 @@ * the key to be deleted from the cache. */ import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; public class MemorystoreDeleteItem { @@ -43,22 +44,23 @@ public class MemorystoreDeleteItem { public static void main(String[] args) { /** Connect to your Memorystore for Valkey instance */ - Jedis jedis = new Jedis(instanceId, port); + JedisPool pool = new JedisPool(instanceId, port); - /** Delete the item from the cache */ - Long result = jedis.del(itemId); + /** Run try with resource */ + try (Jedis jedis = pool.getResource()) { - /** Check if any items have been successfully deleted */ - if (result > 0) { - System.out.println("Successfully deleted item with ID: " + itemId); - } + /** Delete the item from the cache */ + Long result = jedis.del(itemId); - /* Print out that no item has been found for deletion */ - if (result == 0) { - System.out.println("No item found with ID: " + itemId); - } + /** Check if any items have been successfully deleted */ + if (result > 0) { + System.out.println("Successfully deleted item with ID: " + itemId); + } - /** Close the Redis connection */ - jedis.close(); + /* Print out that no item has been found for deletion */ + if (result == 0) { + System.out.println("No item found with ID: " + itemId); + } + } } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java index c9819bbdd76..0a3362d074b 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java @@ -27,6 +27,7 @@ * an actual cached item ID. */ import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; public class MemorystoreReadItem { @@ -43,19 +44,23 @@ public class MemorystoreReadItem { public static void main(String[] args) { /** Connect to your Memorystore for Valkey instance */ - Jedis jedis = new Jedis(instanceId, port); + JedisPool pool = new JedisPool(instanceId, port); - /** Read the cached item */ - String cachedItem = jedis.get(itemId); + /** Run try with resource */ + try (Jedis jedis = pool.getResource()) { - /* If found, print out the cached item */ - if (cachedItem != null) { - System.out.println("Cached item: " + cachedItem); - } + /** Read the cached item */ + String cachedItem = jedis.get(itemId); + + /* If found, print out the cached item */ + if (cachedItem != null) { + System.out.println("Cached item: " + cachedItem); + } - /** If no item found, print a message */ - if (cachedItem == null) { - System.out.println("No cached item found with ID: " + itemId); + /** If no item found, print a message */ + if (cachedItem == null) { + System.out.println("No cached item found with ID: " + itemId); + } } } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java index 8106dfa07c9..baec348bd8b 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java @@ -26,6 +26,7 @@ * "ITEM_VALUE" with the key and value of the item to cache. */ import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; public class MemorystoreTTLItem { @@ -45,44 +46,51 @@ public class MemorystoreTTLItem { public static void main(String[] args) throws InterruptedException { /** Connect to your Memorystore for Valkey instance */ - Jedis jedis = new Jedis(instanceId, port); + JedisPool pool = new JedisPool(instanceId, port); - /** Set a TTL of 10 seconds during entry creation */ - int ttlSeconds = 10; + /** Run try with resource */ + try (Jedis jedis = pool.getResource()) { - /** Create a new cached item with a TTL value */ - jedis.setex(itemId, ttlSeconds, itemValue); + /** Set a TTL of 10 seconds during entry creation */ + int ttlSeconds = 10; - /** Print out the cached item details */ - System.out.println( - "Item cached with ID: " + itemId + " and value: " + itemValue + " for " + ttlSeconds + "s"); + /** Create a new cached item with a TTL value */ + jedis.setex(itemId, ttlSeconds, itemValue); - /** Wait for 5 seconds */ - System.out.println("Waiting for 5 seconds..."); - Thread.sleep(5000); + /** Print out the cached item details */ + System.out.println( + "Item cached with ID: " + + itemId + + " and value: " + + itemValue + + " for " + + ttlSeconds + + "s"); - /** Retrieve the remaining TTL */ - Long remainingTTL = jedis.ttl(itemId); + /** Wait for 5 seconds */ + System.out.println("Waiting for 5 seconds..."); + Thread.sleep(5000); - /** Find the cached item, and print out the remanining expiry */ - String cachedItem = jedis.get(itemId); + /** Retrieve the remaining TTL */ + Long remainingTTL = jedis.ttl(itemId); - /** Print out the item id with remaining TTL value */ - System.out.println("Remaining TTL for item " + itemId + ": " + remainingTTL + "s"); + /** Find the cached item, and print out the remanining expiry */ + String cachedItem = jedis.get(itemId); - /** Wait for another 6 seconds to demonstrate TTL expiry */ - System.out.println("Waiting for 6 seconds for expiry..."); - Thread.sleep(6000); + /** Print out the item id with remaining TTL value */ + System.out.println("Remaining TTL for item " + itemId + ": " + remainingTTL + "s"); - /** Retrieve the remaining TTL or check item existence */ - remainingTTL = jedis.ttl(itemId); + /** Wait for another 6 seconds to demonstrate TTL expiry */ + System.out.println("Waiting for 6 seconds for expiry..."); + Thread.sleep(6000); - /** If TTL is less than 0, print a message indicating expiration */ - if (remainingTTL < 0) { - System.out.println("Item with ID " + itemId + " has expired and is no longer available."); - } + /** Retrieve the remaining TTL or check item existence */ + remainingTTL = jedis.ttl(itemId); - /** Close the Redis connection */ - jedis.close(); + /** If TTL is less than 0, print a message indicating expiration */ + if (remainingTTL < 0) { + System.out.println("Item with ID " + itemId + " has expired and is no longer available."); + } + } } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index a21aacddb76..e81bc8c633d 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -26,6 +26,7 @@ * "ITEM_VALUE" with the key and value to be cached. */ import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; public class MemorystoreWriteItem { @@ -36,23 +37,25 @@ public class MemorystoreWriteItem { private static final int port = 6379; /** Configure the id of the item to write to Memorystore */ - private static final String itemId = "ITEM_ID"; + private static final String itemId = "ITEM_VALUE"; /** Configure the id of the item to write to Memorystore */ - private static final String itemValue = "ITEM_VALUE"; + private static final String itemValue = "test_three_value"; /* Run the code snippet */ public static void main(String[] args) { - /** Connect to the Memorystore Redis instance */ - Jedis jedis = new Jedis(instanceId, port); - /** Write the item to the cache */ - jedis.set(itemId, itemValue); + /** Connect to your Memorystore for Valkey instance */ + JedisPool pool = new JedisPool(instanceId, port); - /** Print out the cached result */ - System.out.println("Item cached with ID: " + itemId + " and value: " + itemValue); + /** Run try with resource */ + try (Jedis jedis = pool.getResource()) { - /** Close the connection */ - jedis.close(); + /** Write the item to the cache */ + jedis.set(itemId, itemValue); + + /** Print out the cached result */ + System.out.println("Item cached with ID: " + itemId + " and value: " + itemValue); + } } } From c141400f6b281b2a56d456f1092dc70d4be529d0 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 14:55:44 +0000 Subject: [PATCH 11/26] fix(memorystore): ensure the cached item has been successfully cached on writeItem --- .../main/java/samples/MemorystoreWriteItem.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index e81bc8c633d..9564074dec7 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -52,10 +52,23 @@ public static void main(String[] args) { try (Jedis jedis = pool.getResource()) { /** Write the item to the cache */ + System.out.println("Writing cached item with ID: " + itemId + " and value: " + itemValue); jedis.set(itemId, itemValue); - /** Print out the cached result */ - System.out.println("Item cached with ID: " + itemId + " and value: " + itemValue); + /** Read the cached item */ + System.out.println( + "Check the cached item has been written successfully written to the cache"); + String cachedItem = jedis.get(itemId); + + /* If found, print out the cached item */ + if (cachedItem != null) { + System.out.println("Cached item: " + cachedItem); + } + + /** If no item found, print a message */ + if (cachedItem == null) { + System.out.println("No cached item found with ID: " + itemId); + } } } } From 626c3bf4a2ae22844d301890892ebdb32882b888 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 15:05:07 +0000 Subject: [PATCH 12/26] docs(memorystore): readme updated to include terminal guides on setting up a memorystore instance --- memorystore/valkey/caching/snippets/REAMDE.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/memorystore/valkey/caching/snippets/REAMDE.md b/memorystore/valkey/caching/snippets/REAMDE.md index 18add020a92..b3eb3c2a111 100644 --- a/memorystore/valkey/caching/snippets/REAMDE.md +++ b/memorystore/valkey/caching/snippets/REAMDE.md @@ -14,6 +14,18 @@ You must have java installed locally on your machinee. Run `java --version` to c A working instance of Memorystore for Valkey must be available. You can run the [Valkey CLI](https://valkey.io/topics/cli/) for a local instance, or create an instance through the [GCP Platform](https://console.cloud.google.com/memorystore/valkey/instances?). +To setup a live instance, create a new Memorystore instance through the GCloud CLI using the following + +```bash +gcloud redis instances create myinstance --size=2 --region=LOCATION --redis-version=redis_6_x +``` + +Altrernativley, run a local instance through the Valkey CLI + +```bash +valkey-cli +``` + ## Running the sample code Each example contains instructions on any prerequiite configuration. From 5c9fe42c4911866080b33726d3261b17394365dd Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 15:06:31 +0000 Subject: [PATCH 13/26] chore(memorystore): headers updated for the current year --- .../snippets/src/main/java/samples/MemorystoreDeleteItem.java | 2 +- .../snippets/src/main/java/samples/MemorystoreReadItem.java | 2 +- .../snippets/src/main/java/samples/MemorystoreTTLItem.java | 2 +- .../snippets/src/main/java/samples/MemorystoreWriteItem.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java index 9793a377824..d4e239fe64a 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java index 0a3362d074b..cd294b762f1 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java index baec348bd8b..9d86fe8aafd 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index 9564074dec7..b12a0c0572f 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 0384dd876c167def7e4d31fe4dc99195c9737b7e Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 23 Jan 2025 15:32:13 +0000 Subject: [PATCH 14/26] chore(memorstore): updated write item variables --- .../src/main/java/samples/MemorystoreWriteItem.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index b12a0c0572f..a21d78d274a 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -37,10 +37,10 @@ public class MemorystoreWriteItem { private static final int port = 6379; /** Configure the id of the item to write to Memorystore */ - private static final String itemId = "ITEM_VALUE"; + private static final String itemId = "ITEM_ID"; /** Configure the id of the item to write to Memorystore */ - private static final String itemValue = "test_three_value"; + private static final String itemValue = "ITEM_VALUE"; /* Run the code snippet */ public static void main(String[] args) { @@ -62,7 +62,7 @@ public static void main(String[] args) { /* If found, print out the cached item */ if (cachedItem != null) { - System.out.println("Cached item: " + cachedItem); + System.out.println("Found Cached item: " + cachedItem); } /** If no item found, print a message */ From f31a379d2c6e96a20e52a617293fe07cc21902ca Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Fri, 24 Jan 2025 11:32:05 +0000 Subject: [PATCH 15/26] chore(memorstore): added package-info.java --- memorystore/valkey/caching/snippets/pom.xml | 2 +- .../src/main/java/samples/package-info.java | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java diff --git a/memorystore/valkey/caching/snippets/pom.xml b/memorystore/valkey/caching/snippets/pom.xml index 35263730dc2..207cdf7a898 100644 --- a/memorystore/valkey/caching/snippets/pom.xml +++ b/memorystore/valkey/caching/snippets/pom.xml @@ -29,7 +29,7 @@ UTF-8 - 17 + 11 diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java b/memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java new file mode 100644 index 00000000000..643b4e198e2 --- /dev/null +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java @@ -0,0 +1,27 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This package demonstrates Google Cloud Memorystore for Redis. It includes: + * + *

+ */ +package com.example.memorystore; From 26a66ad7d5208ff0ee39802552a86f1d83bae445 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Fri, 24 Jan 2025 11:34:59 +0000 Subject: [PATCH 16/26] chore(memorystore): fixed linting on delete item example --- .../java/samples/MemorystoreDeleteItem.java | 64 ++++----- .../java/samples/MemorystoreReadItem.java | 57 ++++---- .../main/java/samples/MemorystoreTTLItem.java | 127 ++++++++---------- .../java/samples/MemorystoreWriteItem.java | 74 +++++----- 4 files changed, 147 insertions(+), 175 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java index d4e239fe64a..fde89f0754d 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java @@ -14,53 +14,45 @@ * limitations under the License. */ -/** - * This code snippet is part of a tutorial on how to use Memorystore for Valkey. - * - *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code - * snippet. - * - *

Prerequisites: 1. A running Memorystore for Valkey instance. 2. An exisiting item to delete - * from the Memrystore cache. - * - *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" with - * the key to be deleted from the cache. - */ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -public class MemorystoreDeleteItem { +public final class MemorystoreDeleteItem { - /** Configure the Memorystore instance id */ - private static final String instanceId = "INSTANCE_ID"; + /** Replace the instance ID of the Memorystore instance. */ + private static final String INSTANCE_ID = "INSTANCE_ID"; - /** Configure the Memorystore port, if not the default port */ - private static final int port = 6379; + /** Replace the Memorystore port, if not the default port. */ + private static final int PORT = 6379; - /** Configure the id of the item to delete from Memorystore */ - private static final String itemId = "ITEM_ID"; + /** Replace the id of the item to delete from Memorystore. */ + private static final String ITEM_ID = "ITEM_ID"; - /* Run the code snippet */ - public static void main(String[] args) { + private MemorystoreDeleteItem() { + // No-op; won't be called + } - /** Connect to your Memorystore for Valkey instance */ - JedisPool pool = new JedisPool(instanceId, port); + /** + * Deletes an item from Memorystore. + * + * @param args command-line arguments + */ + public static void main(final String[] args) { - /** Run try with resource */ - try (Jedis jedis = pool.getResource()) { + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); - /** Delete the item from the cache */ - Long result = jedis.del(itemId); + try (Jedis jedis = pool.getResource()) { - /** Check if any items have been successfully deleted */ - if (result > 0) { - System.out.println("Successfully deleted item with ID: " + itemId); - } + // Attempt to delete the item + Long result = jedis.del(ITEM_ID); - /* Print out that no item has been found for deletion */ - if (result == 0) { - System.out.println("No item found with ID: " + itemId); - } + // Check if the item was successfully deleted + if (result > 0) { + System.out.println("Deleted item: " + ITEM_ID); + } else { + System.out.println("No item found with ID: " + ITEM_ID); + } + } } - } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java index cd294b762f1..72e1fc282a3 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java @@ -17,11 +17,10 @@ /** * This code snippet demonstrates how to read an item from Google Cloud Memorystore for Redis. * - *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code - * snippet. + *

For details, see: https://cloud.google.com/memorystore/docs/redis * - *

Prerequisites: 1. A running Memorystore for Valkey instance. 2. An exisiting item to read from - * the Memrystore cache. + *

Prerequisites: 1. A running Memorystore for Redis instance. 2. An existing item to read from + * the Memorystore cache. * *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" with * an actual cached item ID. @@ -29,38 +28,38 @@ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; +/** Utility class for reading items from Memorystore for Redis. */ public class MemorystoreReadItem { - /** Configure the Memorystore instance id */ - private static final String instanceId = "INSTANCE_ID"; + // Memorystore instance configuration + private static final String INSTANCE_ID = "INSTANCE_ID"; + private static final int PORT = 6379; + private static final String ITEM_ID = "ITEM_ID"; - /** Configure the Memorystore port, if not the default port */ - private static final int port = 6379; + // Private constructor to prevent instantiation + private MemorystoreReadItem() {} - /** Configure the id of the item to read from Memorystore */ - private static final String itemId = "ITEM_ID"; + /** + * Reads an item from Memorystore. + * + * @param args command-line arguments + */ + public static void main(final String[] args) { - /* Run the code snippet */ - public static void main(String[] args) { + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); - /** Connect to your Memorystore for Valkey instance */ - JedisPool pool = new JedisPool(instanceId, port); + try (Jedis jedis = pool.getResource()) { - /** Run try with resource */ - try (Jedis jedis = pool.getResource()) { + // Attempt to read the cached item + String cachedItem = jedis.get(ITEM_ID); - /** Read the cached item */ - String cachedItem = jedis.get(itemId); - - /* If found, print out the cached item */ - if (cachedItem != null) { - System.out.println("Cached item: " + cachedItem); - } - - /** If no item found, print a message */ - if (cachedItem == null) { - System.out.println("No cached item found with ID: " + itemId); - } + // Print the cached item if found + if (cachedItem != null) { + System.out.println("Cached item: " + cachedItem); + } else { + System.out.println("No cached item found with ID: " + ITEM_ID); + } + } } - } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java index 9d86fe8aafd..67b2f01f365 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java @@ -15,82 +15,71 @@ */ /** - * This code snippet is part of a tutorial on how to use Memorystore for Valkey. + * This code snippet demonstrates how to use TTL (Time-To-Live) with Google Cloud Memorystore for + * Redis. * - *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code - * snippet. + *

For details, see: https://cloud.google.com/memorystore/docs/redis * - *

Prerequisites: 1. A running Memorystore for Valkey instance. - * - *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" and - * "ITEM_VALUE" with the key and value of the item to cache. + *

Prerequisites: 1. A running Memorystore for Redis instance. 2. Replace "INSTANCE_ID", + * "ITEM_ID", and "ITEM_VALUE" with the appropriate values. */ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; +/** Utility class for demonstrating TTL operations with Memorystore for Redis. */ public class MemorystoreTTLItem { - /** Configure the Memorystore instance id */ - private static final String instanceId = "INSTANCE_ID"; - - /** Configure the Memorystore port, if not the default port */ - private static final int port = 6379; - - /** Configure the id of the item to read/write from Memorystore */ - private static final String itemId = "ITEM_ID"; - - /** Configure the value of the item to read/write from Memorystore */ - private static final String itemValue = "ITEM_VALUE"; - - /* Run the code snippet */ - public static void main(String[] args) throws InterruptedException { - - /** Connect to your Memorystore for Valkey instance */ - JedisPool pool = new JedisPool(instanceId, port); - - /** Run try with resource */ - try (Jedis jedis = pool.getResource()) { - - /** Set a TTL of 10 seconds during entry creation */ - int ttlSeconds = 10; - - /** Create a new cached item with a TTL value */ - jedis.setex(itemId, ttlSeconds, itemValue); - - /** Print out the cached item details */ - System.out.println( - "Item cached with ID: " - + itemId - + " and value: " - + itemValue - + " for " - + ttlSeconds - + "s"); - - /** Wait for 5 seconds */ - System.out.println("Waiting for 5 seconds..."); - Thread.sleep(5000); - - /** Retrieve the remaining TTL */ - Long remainingTTL = jedis.ttl(itemId); - - /** Find the cached item, and print out the remanining expiry */ - String cachedItem = jedis.get(itemId); - - /** Print out the item id with remaining TTL value */ - System.out.println("Remaining TTL for item " + itemId + ": " + remainingTTL + "s"); - - /** Wait for another 6 seconds to demonstrate TTL expiry */ - System.out.println("Waiting for 6 seconds for expiry..."); - Thread.sleep(6000); - - /** Retrieve the remaining TTL or check item existence */ - remainingTTL = jedis.ttl(itemId); - - /** If TTL is less than 0, print a message indicating expiration */ - if (remainingTTL < 0) { - System.out.println("Item with ID " + itemId + " has expired and is no longer available."); - } + // Memorystore instance configuration + private static final String INSTANCE_ID = "INSTANCE_ID"; + private static final int PORT = 6379; + private static final String ITEM_ID = "ITEM_ID"; + private static final String ITEM_VALUE = "ITEM_VALUE"; + + /** + * Demonstrates creating a cached item with a TTL, checking its expiration, and observing TTL + * expiry. + * + * @param args command-line arguments + * @throws InterruptedException if the thread sleep is interrupted + */ + public static void main(final String[] args) throws InterruptedException { + + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); + + try (Jedis jedis = pool.getResource()) { + + // Set a TTL of 10 seconds during entry creation + final int ttlSeconds = 10; + jedis.setex(ITEM_ID, ttlSeconds, ITEM_VALUE); + + // Print out the cached item details + System.out.printf( + "Item cached with ID: %s and value: %s for %ds%n", + ITEM_ID, ITEM_VALUE, ttlSeconds); + + // Wait for 5 seconds to demonstrate the TTL countdown + System.out.println("Waiting for 5 seconds..."); + Thread.sleep(5000); + + // Retrieve and print the remaining TTL + Long remainingTTL = jedis.ttl(ITEM_ID); + System.out.printf("Remaining TTL for item %s: %ds%n", ITEM_ID, remainingTTL); + + // Wait for another 6 seconds to demonstrate TTL expiry + System.out.println("Waiting for 6 seconds to let the TTL expire..."); + Thread.sleep(6000); + + // Check the remaining TTL and item existence + remainingTTL = jedis.ttl(ITEM_ID); + if (remainingTTL < 0) { + System.out.printf( + "Item with ID %s has expired and is no longer available.%n", ITEM_ID); + } else { + System.out.printf( + "Item with ID %s is still available with TTL: %ds%n", + ITEM_ID, remainingTTL); + } + } } - } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index a21d78d274a..7d597387215 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -15,60 +15,52 @@ */ /** - * This code snippet is part of a tutorial on how to use Memorystore for Redis. + * This code snippet demonstrates how to write an item to Google Cloud Memorystore for Redis. * - *

See https://cloud.google.com/memorystore/docs/valkey/create-instances before running the code - * snippet. + *

For details, see: https://cloud.google.com/memorystore/docs/redis * - *

Prerequisites: 1. A running Memorystore for Valkey instance. - * - *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" and - * "ITEM_VALUE" with the key and value to be cached. + *

Prerequisites: 1. A running Memorystore for Redis instance. 2. Replace "INSTANCE_ID", + * "ITEM_ID", and "ITEM_VALUE" with actual values. */ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; +/** Utility class for writing items to Memorystore for Redis. */ public class MemorystoreWriteItem { - /** Configure the Memorystore instance id */ - private static final String instanceId = "INSTANCE_ID"; - - /** Configure the Memorystore port, if not the default port */ - private static final int port = 6379; - - /** Configure the id of the item to write to Memorystore */ - private static final String itemId = "ITEM_ID"; - - /** Configure the id of the item to write to Memorystore */ - private static final String itemValue = "ITEM_VALUE"; - - /* Run the code snippet */ - public static void main(String[] args) { + // Memorystore instance configuration + private static final String INSTANCE_ID = "INSTANCE_ID"; + private static final int PORT = 6379; + private static final String ITEM_ID = "ITEM_ID"; + private static final String ITEM_VALUE = "ITEM_VALUE"; - /** Connect to your Memorystore for Valkey instance */ - JedisPool pool = new JedisPool(instanceId, port); + /** + * Writes an item to Memorystore and verifies that it has been successfully written. + * + * @param args command-line arguments + */ + public static void main(String[] args) { - /** Run try with resource */ - try (Jedis jedis = pool.getResource()) { + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); - /** Write the item to the cache */ - System.out.println("Writing cached item with ID: " + itemId + " and value: " + itemValue); - jedis.set(itemId, itemValue); + try (Jedis jedis = pool.getResource()) { - /** Read the cached item */ - System.out.println( - "Check the cached item has been written successfully written to the cache"); - String cachedItem = jedis.get(itemId); + // Write the item to the cache + System.out.printf( + "Writing cached item with ID: %s and value: %s%n", ITEM_ID, ITEM_VALUE); + jedis.set(ITEM_ID, ITEM_VALUE); - /* If found, print out the cached item */ - if (cachedItem != null) { - System.out.println("Found Cached item: " + cachedItem); - } + // Verify the cached item + System.out.println("Verifying that the item has been successfully written..."); + String cachedItem = jedis.get(ITEM_ID); - /** If no item found, print a message */ - if (cachedItem == null) { - System.out.println("No cached item found with ID: " + itemId); - } + // Print the cached item if found + if (cachedItem != null) { + System.out.printf("Found cached item: %s%n", cachedItem); + } else { + System.out.printf("No cached item found with ID: %s%n", ITEM_ID); + } + } } - } } From 580628ae685d1f9aab2d9007544091814277edb5 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Fri, 24 Jan 2025 15:29:46 +0000 Subject: [PATCH 17/26] chore(memorystore): additional updates --- .../src/main/java/samples/MemorystoreDeleteItem.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java index fde89f0754d..c239a9f5327 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java @@ -50,8 +50,11 @@ public static void main(final String[] args) { // Check if the item was successfully deleted if (result > 0) { System.out.println("Deleted item: " + ITEM_ID); - } else { - System.out.println("No item found with ID: " + ITEM_ID); + } + + // Print the cached item not found + if (result == 0) { + System.out.printf("No cached item found: %s%n", ITEM_ID); } } } From 3a922b8bf80d37efd539fa8b94ce734679a3e4e6 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Fri, 24 Jan 2025 15:31:44 +0000 Subject: [PATCH 18/26] fix(memorystore): fixed linting errors on the read item snippet --- .../java/samples/MemorystoreReadItem.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java index 72e1fc282a3..031bb9b51fe 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java @@ -14,30 +14,23 @@ * limitations under the License. */ -/** - * This code snippet demonstrates how to read an item from Google Cloud Memorystore for Redis. - * - *

For details, see: https://cloud.google.com/memorystore/docs/redis - * - *

Prerequisites: 1. A running Memorystore for Redis instance. 2. An existing item to read from - * the Memorystore cache. - * - *

Replace "INSTANCE_ID" with the private IP of your Memorystore instance. Replace "ITEM_ID" with - * an actual cached item ID. - */ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -/** Utility class for reading items from Memorystore for Redis. */ -public class MemorystoreReadItem { +public final class MemorystoreReadItem { - // Memorystore instance configuration + /** Replace the instance ID of the Memorystore instance. */ private static final String INSTANCE_ID = "INSTANCE_ID"; + + /** If valid, replace the port number of the Memorystore instance. */ private static final int PORT = 6379; + + /** Replace, the ID of the item to delete from the cache. */ private static final String ITEM_ID = "ITEM_ID"; - // Private constructor to prevent instantiation - private MemorystoreReadItem() {} + private MemorystoreReadItem() { + // No-op; won't be called + } /** * Reads an item from Memorystore. @@ -57,8 +50,11 @@ public static void main(final String[] args) { // Print the cached item if found if (cachedItem != null) { System.out.println("Cached item: " + cachedItem); - } else { - System.out.println("No cached item found with ID: " + ITEM_ID); + } + + // Print the cached item not found + if (cachedItem == null) { + System.out.printf("No cached item found: %s%n", ITEM_ID); } } } From 828f9c21032bab012dd8c04999a2784f17b3f4c5 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Fri, 24 Jan 2025 15:32:44 +0000 Subject: [PATCH 19/26] fix(memorystore): fixed linting errors on the ttl item snippet --- .../main/java/samples/MemorystoreTTLItem.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java index 67b2f01f365..2c172122c96 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java @@ -14,30 +14,35 @@ * limitations under the License. */ -/** - * This code snippet demonstrates how to use TTL (Time-To-Live) with Google Cloud Memorystore for - * Redis. - * - *

For details, see: https://cloud.google.com/memorystore/docs/redis - * - *

Prerequisites: 1. A running Memorystore for Redis instance. 2. Replace "INSTANCE_ID", - * "ITEM_ID", and "ITEM_VALUE" with the appropriate values. - */ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -/** Utility class for demonstrating TTL operations with Memorystore for Redis. */ -public class MemorystoreTTLItem { +public final class MemorystoreTTLItem { - // Memorystore instance configuration + /** Replace the Memorystore instance id. */ private static final String INSTANCE_ID = "INSTANCE_ID"; + + /** Replace the Memorystore port, if not the default port. */ private static final int PORT = 6379; + + /** Replace the id of the item to write to Memorystore. */ private static final String ITEM_ID = "ITEM_ID"; + + /** Replace the id of the item to write to Memorystore. */ private static final String ITEM_VALUE = "ITEM_VALUE"; + /** Set the initial wait time for checking the cache. */ + private static final int INITIAL_WAIT_TIME = 5000; + + /** Set the final wait time for checking the cache. */ + private static final int FINAL_WAIT_TIME = 6000; + + private MemorystoreTTLItem() { + // No-op; won't be called + } + /** - * Demonstrates creating a cached item with a TTL, checking its expiration, and observing TTL - * expiry. + * Writes to Memorystore with a Time-to-live(TTL) value. * * @param args command-line arguments * @throws InterruptedException if the thread sleep is interrupted @@ -60,25 +65,24 @@ public static void main(final String[] args) throws InterruptedException { // Wait for 5 seconds to demonstrate the TTL countdown System.out.println("Waiting for 5 seconds..."); - Thread.sleep(5000); + Thread.sleep(INITIAL_WAIT_TIME); // Retrieve and print the remaining TTL Long remainingTTL = jedis.ttl(ITEM_ID); - System.out.printf("Remaining TTL for item %s: %ds%n", ITEM_ID, remainingTTL); + System.out.printf("Remaining TTL %s: %ds%n", ITEM_ID, remainingTTL); // Wait for another 6 seconds to demonstrate TTL expiry - System.out.println("Waiting for 6 seconds to let the TTL expire..."); - Thread.sleep(6000); + System.out.println("Waiting for 6s for TTL expiry..."); + Thread.sleep(FINAL_WAIT_TIME); // Check the remaining TTL and item existence remainingTTL = jedis.ttl(ITEM_ID); if (remainingTTL < 0) { - System.out.printf( - "Item with ID %s has expired and is no longer available.%n", ITEM_ID); - } else { - System.out.printf( - "Item with ID %s is still available with TTL: %ds%n", - ITEM_ID, remainingTTL); + System.out.printf("Item with ID %s has expired.", ITEM_ID); + } + + if (remainingTTL >= 0) { + System.out.printf("Found Item %s", ITEM_ID, remainingTTL); } } } From 478abb9b0d2870693bc0fcdc902c64a0b13c19e6 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Fri, 24 Jan 2025 15:33:37 +0000 Subject: [PATCH 20/26] fix(memorystore): fixed linting errors on the write item snippet --- .../java/samples/MemorystoreWriteItem.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index 7d597387215..bec8054ccf1 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -14,52 +14,55 @@ * limitations under the License. */ -/** - * This code snippet demonstrates how to write an item to Google Cloud Memorystore for Redis. - * - *

For details, see: https://cloud.google.com/memorystore/docs/redis - * - *

Prerequisites: 1. A running Memorystore for Redis instance. 2. Replace "INSTANCE_ID", - * "ITEM_ID", and "ITEM_VALUE" with actual values. - */ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -/** Utility class for writing items to Memorystore for Redis. */ -public class MemorystoreWriteItem { +public final class MemorystoreWriteItem { - // Memorystore instance configuration + /** Replace the Memorystore instance id. */ private static final String INSTANCE_ID = "INSTANCE_ID"; + + /** Replace the Memorystore port, if not the default port. */ private static final int PORT = 6379; + + /** Replace the id of the item to write to Memorystore. */ private static final String ITEM_ID = "ITEM_ID"; + + /** Replace the id of the item to write to Memorystore. */ private static final String ITEM_VALUE = "ITEM_VALUE"; + private MemorystoreWriteItem() { + // No-op; won't be called + } + /** - * Writes an item to Memorystore and verifies that it has been successfully written. + * Writes to Memorystore before verifying the item exists. * * @param args command-line arguments */ - public static void main(String[] args) { + public static void main(final String[] args) { // Connect to the Memorystore instance JedisPool pool = new JedisPool(INSTANCE_ID, PORT); try (Jedis jedis = pool.getResource()) { - // Write the item to the cache - System.out.printf( - "Writing cached item with ID: %s and value: %s%n", ITEM_ID, ITEM_VALUE); + // Write the item to the cache. + System.out.printf("Caching item %s %s%n", ITEM_ID, ITEM_VALUE); jedis.set(ITEM_ID, ITEM_VALUE); // Verify the cached item - System.out.println("Verifying that the item has been successfully written..."); + System.out.println("Verifying cache."); String cachedItem = jedis.get(ITEM_ID); // Print the cached item if found if (cachedItem != null) { System.out.printf("Found cached item: %s%n", cachedItem); - } else { - System.out.printf("No cached item found with ID: %s%n", ITEM_ID); + } + + // Print the cached item not found + if (cachedItem == null) { + System.out.printf("No cached item found: %s%n", ITEM_ID); } } } From 765a0784502a894f07dff0efb605423c640856dd Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Fri, 24 Jan 2025 16:05:57 +0000 Subject: [PATCH 21/26] chore(memorystore): added header to package-info.java --- .../caching/snippets/src/main/java/samples/package-info.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java b/memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java index 643b4e198e2..429a0d1a6ff 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 9bf2a148802b60dcf0b768ab5989b93227f206d1 Mon Sep 17 00:00:00 2001 From: Jacob Cable Date: Thu, 6 Feb 2025 12:37:54 +0000 Subject: [PATCH 22/26] chore(memorstore-caching-snippets): lint --- .../caching/snippets/{REAMDE.md => README.md} | 2 +- memorystore/valkey/caching/snippets/pom.xml | 10 ++ .../java/samples/MemorystoreDeleteItem.java | 58 ++++----- .../java/samples/MemorystoreReadItem.java | 58 ++++----- .../main/java/samples/MemorystoreTTLItem.java | 120 +++++++++--------- .../java/samples/MemorystoreWriteItem.java | 70 +++++----- 6 files changed, 164 insertions(+), 154 deletions(-) rename memorystore/valkey/caching/snippets/{REAMDE.md => README.md} (94%) diff --git a/memorystore/valkey/caching/snippets/REAMDE.md b/memorystore/valkey/caching/snippets/README.md similarity index 94% rename from memorystore/valkey/caching/snippets/REAMDE.md rename to memorystore/valkey/caching/snippets/README.md index b3eb3c2a111..52852cf1df7 100644 --- a/memorystore/valkey/caching/snippets/REAMDE.md +++ b/memorystore/valkey/caching/snippets/README.md @@ -39,5 +39,5 @@ mvn compile ## Run the sample code ```bash -mvn exec:java -Dexec.mainClass=MemorystoreTTLItem #Replace the main class as needed +mvn exec:java -Dexec.mainClass=MemorystoreTtlItem #Replace the main class as needed ``` diff --git a/memorystore/valkey/caching/snippets/pom.xml b/memorystore/valkey/caching/snippets/pom.xml index 207cdf7a898..3cf09ab497f 100644 --- a/memorystore/valkey/caching/snippets/pom.xml +++ b/memorystore/valkey/caching/snippets/pom.xml @@ -27,6 +27,16 @@ Google Cloud Memorystore Sample http://www.example.com + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + UTF-8 11 diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java index c239a9f5327..f14480ec150 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreDeleteItem.java @@ -19,43 +19,43 @@ public final class MemorystoreDeleteItem { - /** Replace the instance ID of the Memorystore instance. */ - private static final String INSTANCE_ID = "INSTANCE_ID"; + /** Replace the instance ID of the Memorystore instance. */ + private static final String INSTANCE_ID = "INSTANCE_ID"; - /** Replace the Memorystore port, if not the default port. */ - private static final int PORT = 6379; + /** Replace the Memorystore port, if not the default port. */ + private static final int PORT = 6379; - /** Replace the id of the item to delete from Memorystore. */ - private static final String ITEM_ID = "ITEM_ID"; + /** Replace the id of the item to delete from Memorystore. */ + private static final String ITEM_ID = "ITEM_ID"; - private MemorystoreDeleteItem() { - // No-op; won't be called - } + private MemorystoreDeleteItem() { + // No-op; won't be called + } - /** - * Deletes an item from Memorystore. - * - * @param args command-line arguments - */ - public static void main(final String[] args) { + /** + * Deletes an item from Memorystore. + * + * @param args command-line arguments + */ + public static void main(final String[] args) { - // Connect to the Memorystore instance - JedisPool pool = new JedisPool(INSTANCE_ID, PORT); + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); - try (Jedis jedis = pool.getResource()) { + try (Jedis jedis = pool.getResource()) { - // Attempt to delete the item - Long result = jedis.del(ITEM_ID); + // Attempt to delete the item + Long result = jedis.del(ITEM_ID); - // Check if the item was successfully deleted - if (result > 0) { - System.out.println("Deleted item: " + ITEM_ID); - } + // Check if the item was successfully deleted + if (result > 0) { + System.out.println("Deleted item: " + ITEM_ID); + } - // Print the cached item not found - if (result == 0) { - System.out.printf("No cached item found: %s%n", ITEM_ID); - } - } + // Print the cached item not found + if (result == 0) { + System.out.printf("No cached item found: %s%n", ITEM_ID); + } } + } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java index 031bb9b51fe..f315ab797f4 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreReadItem.java @@ -19,43 +19,43 @@ public final class MemorystoreReadItem { - /** Replace the instance ID of the Memorystore instance. */ - private static final String INSTANCE_ID = "INSTANCE_ID"; + /** Replace the instance ID of the Memorystore instance. */ + private static final String INSTANCE_ID = "INSTANCE_ID"; - /** If valid, replace the port number of the Memorystore instance. */ - private static final int PORT = 6379; + /** If valid, replace the port number of the Memorystore instance. */ + private static final int PORT = 6379; - /** Replace, the ID of the item to delete from the cache. */ - private static final String ITEM_ID = "ITEM_ID"; + /** Replace, the ID of the item to delete from the cache. */ + private static final String ITEM_ID = "ITEM_ID"; - private MemorystoreReadItem() { - // No-op; won't be called - } + private MemorystoreReadItem() { + // No-op; won't be called + } - /** - * Reads an item from Memorystore. - * - * @param args command-line arguments - */ - public static void main(final String[] args) { + /** + * Reads an item from Memorystore. + * + * @param args command-line arguments + */ + public static void main(final String[] args) { - // Connect to the Memorystore instance - JedisPool pool = new JedisPool(INSTANCE_ID, PORT); + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); - try (Jedis jedis = pool.getResource()) { + try (Jedis jedis = pool.getResource()) { - // Attempt to read the cached item - String cachedItem = jedis.get(ITEM_ID); + // Attempt to read the cached item + String cachedItem = jedis.get(ITEM_ID); - // Print the cached item if found - if (cachedItem != null) { - System.out.println("Cached item: " + cachedItem); - } + // Print the cached item if found + if (cachedItem != null) { + System.out.println("Cached item: " + cachedItem); + } - // Print the cached item not found - if (cachedItem == null) { - System.out.printf("No cached item found: %s%n", ITEM_ID); - } - } + // Print the cached item not found + if (cachedItem == null) { + System.out.printf("No cached item found: %s%n", ITEM_ID); + } } + } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java index 2c172122c96..bc1d1dcb81b 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreTTLItem.java @@ -17,73 +17,73 @@ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -public final class MemorystoreTTLItem { +public final class MemorystoreTtlItem { - /** Replace the Memorystore instance id. */ - private static final String INSTANCE_ID = "INSTANCE_ID"; + /** Replace the Memorystore instance id. */ + private static final String INSTANCE_ID = "INSTANCE_ID"; - /** Replace the Memorystore port, if not the default port. */ - private static final int PORT = 6379; + /** Replace the Memorystore port, if not the default port. */ + private static final int PORT = 6379; - /** Replace the id of the item to write to Memorystore. */ - private static final String ITEM_ID = "ITEM_ID"; + /** Replace the id of the item to write to Memorystore. */ + private static final String ITEM_ID = "ITEM_ID"; - /** Replace the id of the item to write to Memorystore. */ - private static final String ITEM_VALUE = "ITEM_VALUE"; + /** Replace the id of the item to write to Memorystore. */ + private static final String ITEM_VALUE = "ITEM_VALUE"; - /** Set the initial wait time for checking the cache. */ - private static final int INITIAL_WAIT_TIME = 5000; + /** Set the initial wait time for checking the cache. */ + private static final int INITIAL_WAIT_TIME = 5000; - /** Set the final wait time for checking the cache. */ - private static final int FINAL_WAIT_TIME = 6000; + /** Set the final wait time for checking the cache. */ + private static final int FINAL_WAIT_TIME = 6000; - private MemorystoreTTLItem() { - // No-op; won't be called - } + private MemorystoreTtlItem() { + // No-op; won't be called + } + + /** + * Writes to Memorystore with a Time-to-live(TTL) value. + * + * @param args command-line arguments + * @throws InterruptedException if the thread sleep is interrupted + */ + public static void main(final String[] args) throws InterruptedException { + + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); + + try (Jedis jedis = pool.getResource()) { + + // Set a TTL of 10 seconds during entry creation + final int ttlSeconds = 10; + jedis.setex(ITEM_ID, ttlSeconds, ITEM_VALUE); + + // Print out the cached item details + System.out.printf( + "Item cached with ID: %s and value: %s for %ds%n", + ITEM_ID, ITEM_VALUE, ttlSeconds); + + // Wait for 5 seconds to demonstrate the TTL countdown + System.out.println("Waiting for 5 seconds..."); + Thread.sleep(INITIAL_WAIT_TIME); + + // Retrieve and print the remaining TTL + Long remainingTtl = jedis.ttl(ITEM_ID); + System.out.printf("Remaining TTL %s: %ds%n", ITEM_ID, remainingTtl); + + // Wait for another 6 seconds to demonstrate TTL expiry + System.out.println("Waiting for 6s for TTL expiry..."); + Thread.sleep(FINAL_WAIT_TIME); + + // Check the remaining TTL and item existence + remainingTtl = jedis.ttl(ITEM_ID); + if (remainingTtl < 0) { + System.out.printf("Item with ID %s has expired.", ITEM_ID); + } - /** - * Writes to Memorystore with a Time-to-live(TTL) value. - * - * @param args command-line arguments - * @throws InterruptedException if the thread sleep is interrupted - */ - public static void main(final String[] args) throws InterruptedException { - - // Connect to the Memorystore instance - JedisPool pool = new JedisPool(INSTANCE_ID, PORT); - - try (Jedis jedis = pool.getResource()) { - - // Set a TTL of 10 seconds during entry creation - final int ttlSeconds = 10; - jedis.setex(ITEM_ID, ttlSeconds, ITEM_VALUE); - - // Print out the cached item details - System.out.printf( - "Item cached with ID: %s and value: %s for %ds%n", - ITEM_ID, ITEM_VALUE, ttlSeconds); - - // Wait for 5 seconds to demonstrate the TTL countdown - System.out.println("Waiting for 5 seconds..."); - Thread.sleep(INITIAL_WAIT_TIME); - - // Retrieve and print the remaining TTL - Long remainingTTL = jedis.ttl(ITEM_ID); - System.out.printf("Remaining TTL %s: %ds%n", ITEM_ID, remainingTTL); - - // Wait for another 6 seconds to demonstrate TTL expiry - System.out.println("Waiting for 6s for TTL expiry..."); - Thread.sleep(FINAL_WAIT_TIME); - - // Check the remaining TTL and item existence - remainingTTL = jedis.ttl(ITEM_ID); - if (remainingTTL < 0) { - System.out.printf("Item with ID %s has expired.", ITEM_ID); - } - - if (remainingTTL >= 0) { - System.out.printf("Found Item %s", ITEM_ID, remainingTTL); - } - } + if (remainingTtl >= 0) { + System.out.printf("Found Item %s", ITEM_ID, remainingTtl); + } } + } } diff --git a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java index bec8054ccf1..b1ec34aae66 100644 --- a/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java +++ b/memorystore/valkey/caching/snippets/src/main/java/samples/MemorystoreWriteItem.java @@ -19,51 +19,51 @@ public final class MemorystoreWriteItem { - /** Replace the Memorystore instance id. */ - private static final String INSTANCE_ID = "INSTANCE_ID"; + /** Replace the Memorystore instance id. */ + private static final String INSTANCE_ID = "INSTANCE_ID"; - /** Replace the Memorystore port, if not the default port. */ - private static final int PORT = 6379; + /** Replace the Memorystore port, if not the default port. */ + private static final int PORT = 6379; - /** Replace the id of the item to write to Memorystore. */ - private static final String ITEM_ID = "ITEM_ID"; + /** Replace the id of the item to write to Memorystore. */ + private static final String ITEM_ID = "ITEM_ID"; - /** Replace the id of the item to write to Memorystore. */ - private static final String ITEM_VALUE = "ITEM_VALUE"; + /** Replace the id of the item to write to Memorystore. */ + private static final String ITEM_VALUE = "ITEM_VALUE"; - private MemorystoreWriteItem() { - // No-op; won't be called - } + private MemorystoreWriteItem() { + // No-op; won't be called + } - /** - * Writes to Memorystore before verifying the item exists. - * - * @param args command-line arguments - */ - public static void main(final String[] args) { + /** + * Writes to Memorystore before verifying the item exists. + * + * @param args command-line arguments + */ + public static void main(final String[] args) { - // Connect to the Memorystore instance - JedisPool pool = new JedisPool(INSTANCE_ID, PORT); + // Connect to the Memorystore instance + JedisPool pool = new JedisPool(INSTANCE_ID, PORT); - try (Jedis jedis = pool.getResource()) { + try (Jedis jedis = pool.getResource()) { - // Write the item to the cache. - System.out.printf("Caching item %s %s%n", ITEM_ID, ITEM_VALUE); - jedis.set(ITEM_ID, ITEM_VALUE); + // Write the item to the cache. + System.out.printf("Caching item %s %s%n", ITEM_ID, ITEM_VALUE); + jedis.set(ITEM_ID, ITEM_VALUE); - // Verify the cached item - System.out.println("Verifying cache."); - String cachedItem = jedis.get(ITEM_ID); + // Verify the cached item + System.out.println("Verifying cache."); + String cachedItem = jedis.get(ITEM_ID); - // Print the cached item if found - if (cachedItem != null) { - System.out.printf("Found cached item: %s%n", cachedItem); - } + // Print the cached item if found + if (cachedItem != null) { + System.out.printf("Found cached item: %s%n", cachedItem); + } - // Print the cached item not found - if (cachedItem == null) { - System.out.printf("No cached item found: %s%n", ITEM_ID); - } - } + // Print the cached item not found + if (cachedItem == null) { + System.out.printf("No cached item found: %s%n", ITEM_ID); + } } + } } From 6eefe92d4ada79d3a13088fc9ea5e39d4a751ffc Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Thu, 6 Feb 2025 21:47:09 +0000 Subject: [PATCH 23/26] docs(caching): updated valkey cli cluster link --- memorystore/valkey/caching/snippets/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memorystore/valkey/caching/snippets/README.md b/memorystore/valkey/caching/snippets/README.md index 52852cf1df7..41ab58ebfd1 100644 --- a/memorystore/valkey/caching/snippets/README.md +++ b/memorystore/valkey/caching/snippets/README.md @@ -12,7 +12,7 @@ You must have java installed locally on your machinee. Run `java --version` to c ### Memorystore for Valkey Instance -A working instance of Memorystore for Valkey must be available. You can run the [Valkey CLI](https://valkey.io/topics/cli/) for a local instance, or create an instance through the [GCP Platform](https://console.cloud.google.com/memorystore/valkey/instances?). +A working instance of Memorystore for Valkey must be available. You can run the [Valkey CLI](https://valkey.io/topics/cluster-tutorial/#create-a-valkey-cluster) for a local instance, or create an instance through the [GCP Platform](https://console.cloud.google.com/memorystore/valkey/instances?). To setup a live instance, create a new Memorystore instance through the GCloud CLI using the following From 71f49343b58ce8825b5c8fec2a42955e5990cca1 Mon Sep 17 00:00:00 2001 From: Corie Watson Date: Fri, 7 Feb 2025 13:44:20 +0000 Subject: [PATCH 24/26] chore(caching): fix license --- memorystore/valkey/caching/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memorystore/valkey/caching/snippets/pom.xml b/memorystore/valkey/caching/snippets/pom.xml index 3cf09ab497f..320e63a8d0a 100644 --- a/memorystore/valkey/caching/snippets/pom.xml +++ b/memorystore/valkey/caching/snippets/pom.xml @@ -1,7 +1,7 @@