diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f5ea4da8a..a36a7f60fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ #### Changes +* Java: Replace instances of Redis with Valkey ([#2268](https://github.com/valkey-io/valkey-glide/pull/2268)) * Node: Replace instances of Redis with Valkey ([#2260](https://github.com/valkey-io/valkey-glide/pull/2260)) * Java: Fetch server version using info command ([#2258](https://github.com/valkey-io/valkey-glide/pull/2258)) * Node: Added binary variant for commands which have `Record` as input or output ([#2207](https://github.com/valkey-io/valkey-glide/pull/2207)) diff --git a/java/benchmarks/src/main/java/glide/benchmarks/BenchmarkingApp.java b/java/benchmarks/src/main/java/glide/benchmarks/BenchmarkingApp.java index 7f7f2de254..b610170e92 100644 --- a/java/benchmarks/src/main/java/glide/benchmarks/BenchmarkingApp.java +++ b/java/benchmarks/src/main/java/glide/benchmarks/BenchmarkingApp.java @@ -17,7 +17,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; -/** Benchmarking app for reporting performance of various Redis Java-clients */ +/** Benchmarking app for reporting performance of various Valkey Java-clients */ public class BenchmarkingApp { // main application entrypoint @@ -55,7 +55,7 @@ public static void main(String[] args) { testClientSetGet(LettuceAsyncClient::new, runConfiguration, true); break; case GLIDE: - System.out.println("GLIDE for Redis async client"); + System.out.println("Valkey-GLIDE async client"); testClientSetGet(GlideAsyncClient::new, runConfiguration, true); break; } diff --git a/java/benchmarks/src/main/java/glide/benchmarks/clients/AsyncClient.java b/java/benchmarks/src/main/java/glide/benchmarks/clients/AsyncClient.java index 8a6c8a9025..f498ba74b0 100644 --- a/java/benchmarks/src/main/java/glide/benchmarks/clients/AsyncClient.java +++ b/java/benchmarks/src/main/java/glide/benchmarks/clients/AsyncClient.java @@ -6,7 +6,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -/** A Redis client with async capabilities */ +/** A Valkey client with async capabilities */ public interface AsyncClient extends Client { long DEFAULT_TIMEOUT_MILLISECOND = 1000; diff --git a/java/benchmarks/src/main/java/glide/benchmarks/clients/Client.java b/java/benchmarks/src/main/java/glide/benchmarks/clients/Client.java index 1db6466659..1072f9db69 100644 --- a/java/benchmarks/src/main/java/glide/benchmarks/clients/Client.java +++ b/java/benchmarks/src/main/java/glide/benchmarks/clients/Client.java @@ -3,7 +3,7 @@ import glide.benchmarks.utils.ConnectionSettings; -/** A Redis client interface */ +/** A Valkey client interface */ public interface Client { void connectToValkey(ConnectionSettings connectionSettings); diff --git a/java/benchmarks/src/main/java/glide/benchmarks/clients/SyncClient.java b/java/benchmarks/src/main/java/glide/benchmarks/clients/SyncClient.java index f8034435ae..41bab3a3c5 100644 --- a/java/benchmarks/src/main/java/glide/benchmarks/clients/SyncClient.java +++ b/java/benchmarks/src/main/java/glide/benchmarks/clients/SyncClient.java @@ -1,7 +1,7 @@ /** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ package glide.benchmarks.clients; -/** A Redis client with sync capabilities */ +/** A Valkey client with sync capabilities */ public interface SyncClient extends Client { void set(String key, String value); diff --git a/java/benchmarks/src/main/java/glide/benchmarks/utils/ConnectionSettings.java b/java/benchmarks/src/main/java/glide/benchmarks/utils/ConnectionSettings.java index e8eae01a1b..8721ddec15 100644 --- a/java/benchmarks/src/main/java/glide/benchmarks/utils/ConnectionSettings.java +++ b/java/benchmarks/src/main/java/glide/benchmarks/utils/ConnectionSettings.java @@ -1,7 +1,7 @@ /** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ package glide.benchmarks.utils; -/** Redis-client settings */ +/** Valkey-client settings */ public class ConnectionSettings { public final String host; public final int port; diff --git a/java/client/src/main/java/glide/api/models/commands/scan/ZScanOptionsBinary.java b/java/client/src/main/java/glide/api/models/commands/scan/ZScanOptionsBinary.java index d93a0b1e06..189179ca35 100644 --- a/java/client/src/main/java/glide/api/models/commands/scan/ZScanOptionsBinary.java +++ b/java/client/src/main/java/glide/api/models/commands/scan/ZScanOptionsBinary.java @@ -25,7 +25,7 @@ public class ZScanOptionsBinary extends BaseScanOptionsBinary { /** * When set to true, the command will not include scores in the results. This option is available - * from Redis version 8.0.0 and above. + * from Valkey version 8.0.0 and above. */ @Builder.Default protected boolean noScores = false; diff --git a/java/client/src/test/java/glide/ffi/FfiTest.java b/java/client/src/test/java/glide/ffi/FfiTest.java index d5e33e7736..5a118c6af4 100644 --- a/java/client/src/test/java/glide/ffi/FfiTest.java +++ b/java/client/src/test/java/glide/ffi/FfiTest.java @@ -58,7 +58,7 @@ public static native void throwException( boolean throwTwice, boolean isRuntimeException, String message); @Test - public void redisValueToJavaValue_Nil() { + public void respValueToJavaValue_Nil() { long ptr = FfiTest.createLeakedNil(); Object nilValue = GlideValueResolver.valueFromPointer(ptr); assertNull(nilValue); @@ -66,14 +66,14 @@ public void redisValueToJavaValue_Nil() { @ParameterizedTest @ValueSource(strings = {"hello", "cat", "dog"}) - public void redisValueToJavaValue_SimpleString(String input) { + public void respValueToJavaValue_SimpleString(String input) { long ptr = FfiTest.createLeakedSimpleString(input); Object simpleStringValue = GlideValueResolver.valueFromPointer(ptr); assertEquals(input, simpleStringValue); } @Test - public void redisValueToJavaValue_Okay() { + public void respValueToJavaValue_Okay() { long ptr = FfiTest.createLeakedOkay(); Object okayValue = GlideValueResolver.valueFromPointer(ptr); assertEquals("OK", okayValue); @@ -81,7 +81,7 @@ public void redisValueToJavaValue_Okay() { @ParameterizedTest @ValueSource(longs = {0L, 100L, 774L, Integer.MAX_VALUE + 1L, Integer.MIN_VALUE - 1L}) - public void redisValueToJavaValue_Int(Long input) { + public void respValueToJavaValue_Int(Long input) { long ptr = FfiTest.createLeakedInt(input); Object longValue = GlideValueResolver.valueFromPointer(ptr); assertTrue(longValue instanceof Long); @@ -90,7 +90,7 @@ public void redisValueToJavaValue_Int(Long input) { @Test @SneakyThrows - public void redisValueToJavaValue_BulkString() { + public void respValueToJavaValue_BulkString() { // This is explicitly for testing non-ASCII UTF-8 byte sequences. // Note that these can't be encoded as String literals without introducing compiler // warnings and errors. @@ -105,7 +105,7 @@ public void redisValueToJavaValue_BulkString() { } @Test - public void redisValueToJavaValue_Array() { + public void respValueToJavaValue_Array() { long[] array = {1L, 2L, 3L}; long ptr = FfiTest.createLeakedLongArray(array); Object longArrayValue = GlideValueResolver.valueFromPointer(ptr); @@ -115,7 +115,7 @@ public void redisValueToJavaValue_Array() { } @Test - public void redisValueToJavaValue_Map() { + public void respValueToJavaValue_Map() { long[] keys = {12L, 14L, 23L}; long[] values = {1L, 2L, 3L}; long ptr = FfiTest.createLeakedMap(keys, values); @@ -130,14 +130,14 @@ public void redisValueToJavaValue_Map() { @ParameterizedTest @ValueSource(doubles = {1.0d, 25.2d, 103.5d}) - public void redisValueToJavaValue_Double(Double input) { + public void respValueToJavaValue_Double(Double input) { long ptr = FfiTest.createLeakedDouble(input); Object doubleValue = GlideValueResolver.valueFromPointer(ptr); assertEquals(input, doubleValue); } @Test - public void redisValueToJavaValue_Boolean() { + public void respValueToJavaValue_Boolean() { long ptr = FfiTest.createLeakedBoolean(true); Object booleanValue = GlideValueResolver.valueFromPointer(ptr); assertTrue((Boolean) booleanValue); @@ -145,14 +145,14 @@ public void redisValueToJavaValue_Boolean() { @ParameterizedTest @ValueSource(strings = {"hello", "cat", "dog"}) - public void redisValueToJavaValue_VerbatimString(String input) { + public void respValueToJavaValue_VerbatimString(String input) { long ptr = FfiTest.createLeakedVerbatimString(input); Object verbatimStringValue = GlideValueResolver.valueFromPointer(ptr); assertEquals(input, verbatimStringValue); } @Test - public void redisValueToJavaValue_Set() { + public void respValueToJavaValue_Set() { long[] array = {1L, 2L, 2L}; long ptr = FfiTest.createLeakedLongSet(array); Object longSetValue = GlideValueResolver.valueFromPointer(ptr); diff --git a/java/src/ffi_test.rs b/java/src/ffi_test.rs index 03b4e52726..ee3bd4ad32 100644 --- a/java/src/ffi_test.rs +++ b/java/src/ffi_test.rs @@ -14,8 +14,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedNil<'local>( _env: JNIEnv<'local>, _class: JClass<'local>, ) -> jlong { - let redis_value = Value::Nil; - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Nil; + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -25,8 +25,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedSimpleString<'local>( value: JString<'local>, ) -> jlong { let value: String = env.get_string(&value).unwrap().into(); - let redis_value = Value::SimpleString(value); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::SimpleString(value); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -34,8 +34,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedOkay<'local>( _env: JNIEnv<'local>, _class: JClass<'local>, ) -> jlong { - let redis_value = Value::Okay; - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Okay; + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -44,8 +44,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedInt<'local>( _class: JClass<'local>, value: jlong, ) -> jlong { - let redis_value = Value::Int(value); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Int(value); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -56,8 +56,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedBulkString<'local>( ) -> jlong { let value = env.convert_byte_array(&value).unwrap(); let value = value.into_iter().collect::>(); - let redis_value = Value::BulkString(value); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::BulkString(value); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -67,8 +67,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedLongArray<'local>( value: JLongArray<'local>, ) -> jlong { let array = java_long_array_to_value(&mut env, &value); - let redis_value = Value::Array(array); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Array(array); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -81,8 +81,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedMap<'local>( let keys_vec = java_long_array_to_value(&mut env, &keys); let values_vec = java_long_array_to_value(&mut env, &values); let map: Vec<(Value, Value)> = keys_vec.into_iter().zip(values_vec).collect(); - let redis_value = Value::Map(map); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Map(map); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -91,8 +91,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedDouble<'local>( _class: JClass<'local>, value: jdouble, ) -> jlong { - let redis_value = Value::Double(value.into()); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Double(value.into()); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -101,8 +101,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedBoolean<'local>( _class: JClass<'local>, value: jboolean, ) -> jlong { - let redis_value = Value::Boolean(value != 0); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Boolean(value != 0); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -113,11 +113,11 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedVerbatimString<'local> ) -> jlong { use redis::VerbatimFormat; let value: String = env.get_string(&value).unwrap().into(); - let redis_value = Value::VerbatimString { + let resp_value = Value::VerbatimString { format: VerbatimFormat::Text, text: value, }; - Box::leak(Box::new(redis_value)) as *mut Value as jlong + Box::leak(Box::new(resp_value)) as *mut Value as jlong } #[no_mangle] @@ -127,8 +127,8 @@ pub extern "system" fn Java_glide_ffi_FfiTest_createLeakedLongSet<'local>( value: JLongArray<'local>, ) -> jlong { let set = java_long_array_to_value(&mut env, &value); - let redis_value = Value::Set(set); - Box::leak(Box::new(redis_value)) as *mut Value as jlong + let resp_value = Value::Set(set); + Box::leak(Box::new(resp_value)) as *mut Value as jlong } fn java_long_array_to_value<'local>( diff --git a/java/src/lib.rs b/java/src/lib.rs index 467a6f9be8..9036f2daae 100644 --- a/java/src/lib.rs +++ b/java/src/lib.rs @@ -33,7 +33,7 @@ pub use ffi_test::*; struct Level(i32); // TODO: Consider caching method IDs here in a static variable (might need RwLock to mutate) -fn redis_value_to_java<'local>( +fn resp_value_to_java<'local>( env: &mut JNIEnv<'local>, val: Value, encoding_utf8: bool, @@ -62,8 +62,8 @@ fn redis_value_to_java<'local>( let linked_hash_map = env.new_object("java/util/LinkedHashMap", "()V", &[])?; for (key, value) in map { - let java_key = redis_value_to_java(env, key, encoding_utf8)?; - let java_value = redis_value_to_java(env, value, encoding_utf8)?; + let java_key = resp_value_to_java(env, key, encoding_utf8)?; + let java_value = resp_value_to_java(env, value, encoding_utf8)?; env.call_method( &linked_hash_map, "put", @@ -88,7 +88,7 @@ fn redis_value_to_java<'local>( let set = env.new_object("java/util/HashSet", "()V", &[])?; for elem in array { - let java_value = redis_value_to_java(env, elem, encoding_utf8)?; + let java_value = resp_value_to_java(env, elem, encoding_utf8)?; env.call_method( &set, "add", @@ -106,7 +106,7 @@ fn redis_value_to_java<'local>( // Create a java `Map` with two keys: // - "kind" which corresponds to the push type, stored as a `String` // - "values" which corresponds to the array of values received, stored as `Object[]` - // Only string messages are supported now by Redis and `redis-rs`. + // Only string messages are supported now by Valkey and `redis-rs`. Value::Push { kind, data } => { let hash_map = env.new_object("java/util/HashMap", "()V", &[])?; @@ -137,7 +137,7 @@ fn redis_value_to_java<'local>( /// Convert an array of values into java array of corresponding values. /// -/// Recursively calls to [`redis_value_to_java`] for every element. +/// Recursively calls to [`resp_value_to_java`] for every element. /// /// Returns an arbitrary java `Object[]`. fn array_to_java_array<'local>( @@ -149,7 +149,7 @@ fn array_to_java_array<'local>( env.new_object_array(values.len() as i32, "java/lang/Object", JObject::null())?; for (i, item) in values.into_iter().enumerate() { - let java_value = redis_value_to_java(env, item, encoding_utf8)?; + let java_value = resp_value_to_java(env, item, encoding_utf8)?; env.set_object_array_element(&items, i as i32, java_value)?; } @@ -169,7 +169,7 @@ pub extern "system" fn Java_glide_ffi_resolvers_GlideValueResolver_valueFromPoin pointer: jlong, ) -> Result, FFIError> { let value = unsafe { Box::from_raw(pointer as *mut Value) }; - redis_value_to_java(env, *value, true) + resp_value_to_java(env, *value, true) } let result = value_from_pointer(&mut env, pointer); handle_errors(&mut env, result) @@ -194,7 +194,7 @@ pub extern "system" fn Java_glide_ffi_resolvers_GlideValueResolver_valueFromPoin pointer: jlong, ) -> Result, FFIError> { let value = unsafe { Box::from_raw(pointer as *mut Value) }; - redis_value_to_java(env, *value, false) + resp_value_to_java(env, *value, false) } let result = value_from_pointer_binary(&mut env, pointer); handle_errors(&mut env, result)