1
- # Jackey
2
- Jackey is [ Valkey] ( https://github.com/valkey-io/valkey ) 's Java client, derived from [ Jedis] ( https://github.com/redis/jedis ) fork, dedicated to maintaining simplicity and high performance.
1
+ # Valkey-Java
2
+ valkey-java is [ Valkey] ( https://github.com/valkey-io/valkey ) 's Java client, derived from [ Jedis] ( https://github.com/redis/jedis ) fork, dedicated to maintaining simplicity and high performance.
3
3
4
4
5
5
# Getting started
6
6
Add the following dependencies to your ` pom.xml ` file:
7
7
```
8
8
<dependency>
9
- <groupId>io.jackey </groupId>
10
- <artifactId>jackey </artifactId>
11
- <version>5.2.0 </version>
9
+ <groupId>io.valkey </groupId>
10
+ <artifactId>valkey-java </artifactId>
11
+ <version>5.3.0(coming soon) </version>
12
12
</dependency>
13
13
```
14
14
15
15
## Connect to Valkey
16
+
16
17
``` java
17
- public class JackeyTest {
18
+ public class ValkeyTest {
18
19
// can be static or singleton, thread safety.
19
- private static io.jackey . JedisPool jedisPool;
20
-
20
+ private static io.valkey . JedisPool jedisPool;
21
+
21
22
public static void main (String [] args ) {
22
- io.jackey . JedisPoolConfig config = new io.jackey . JedisPoolConfig ();
23
+ io.valkey . JedisPoolConfig config = new io.valkey . JedisPoolConfig ();
23
24
// It is recommended that you set maxTotal = maxIdle = 2*minIdle for best performance
24
25
config. setMaxTotal(32 );
25
26
config. setMaxIdle(32 );
26
27
config. setMinIdle(16 );
27
- jedisPool = new io.jackey . JedisPool (config, < host> , < port> , < timeout> , < password> );
28
- try (io.jackey . Jedis jedis = jedisPool. getResource()) {
28
+ jedisPool = new io.valkey . JedisPool (config, < host > , < port > , < timeout > , < password > );
29
+ try (io.valkey . Jedis jedis = jedisPool. getResource()) {
29
30
jedis. set(" key" , " value" );
30
31
System . out. println(jedis. get(" key" ));
31
32
} catch (Exception e) {
@@ -37,18 +38,20 @@ public class JackeyTest {
37
38
```
38
39
39
40
## Connect to the Valkey cluster
41
+
40
42
``` java
41
43
import java.util.HashSet ;
42
44
import java.util.Set ;
43
- import io.jackey.HostAndPort ;
44
45
45
- public class JackeyClusterTest {
46
+ import io.valkey.HostAndPort ;
47
+
48
+ public class ValkeyClusterTest {
46
49
private static final int DEFAULT_TIMEOUT = 2000 ;
47
50
private static final int DEFAULT_REDIRECTIONS = 5 ;
48
- private static io.jackey . JedisCluster jc; // be static or singleton, thread safety.
51
+ private static io.valkey . JedisCluster jc; // be static or singleton, thread safety.
49
52
50
53
public static void main (String [] args ) {
51
- io.jackey . ConnectionPoolConfig config = new io.jackey . ConnectionPoolConfig ();
54
+ io.valkey . ConnectionPoolConfig config = new io.valkey . ConnectionPoolConfig ();
52
55
// It is recommended that you set maxTotal = maxIdle = 2*minIdle for best performance
53
56
// In cluster mode, please note that each business machine will contain up to maxTotal links,
54
57
// and the total number of connections = maxTotal * number of machines
@@ -58,11 +61,11 @@ public class JackeyClusterTest {
58
61
59
62
Set<HostAndPort > jedisClusterNode = new HashSet<HostAndPort > ();
60
63
jedisClusterNode. add(new HostAndPort (host, port));
61
- jc = new io.jackey . JedisCluster (jedisClusterNode, DEFAULT_TIMEOUT , DEFAULT_TIMEOUT , DEFAULT_REDIRECTIONS ,
64
+ jc = new io.valkey . JedisCluster (jedisClusterNode, DEFAULT_TIMEOUT , DEFAULT_TIMEOUT , DEFAULT_REDIRECTIONS ,
62
65
password, null , config);
63
66
64
67
jc. set(" key" , " value" ); // Note that there is no need to call jc.close() here,
65
- // the connection recycling is actively completed internally.
68
+ // the connection recycling is actively completed internally.
66
69
System . out. println(jc. get(" key" ));
67
70
68
71
jc. close(); // when app exit, close the resource.
@@ -71,19 +74,21 @@ public class JackeyClusterTest {
71
74
```
72
75
73
76
## Connect using TLS method
77
+
74
78
``` java
75
79
import java.io.FileInputStream ;
76
80
import java.io.InputStream ;
77
81
import java.security.KeyStore ;
78
82
import java.security.SecureRandom ;
83
+
79
84
import javax.net.ssl.SSLContext ;
80
85
import javax.net.ssl.SSLSocketFactory ;
81
86
import javax.net.ssl.TrustManager ;
82
87
import javax.net.ssl.TrustManagerFactory ;
83
88
84
89
import org.apache.commons.pool2.impl.GenericObjectPoolConfig ;
85
90
86
- public class JackeySSLTest {
91
+ public class ValkeySSLTest {
87
92
private static SSLSocketFactory createTrustStoreSSLSocketFactory (String jksFile ) throws Exception {
88
93
KeyStore trustStore = KeyStore . getInstance(" jks" );
89
94
InputStream inputStream = null ;
@@ -105,11 +110,11 @@ public class JackeySSLTest {
105
110
106
111
public static void main (String [] args ) throws Exception {
107
112
// When you don't have a jks file, just set sslSocketFactory to null.
108
- final SSLSocketFactory sslSocketFactory = createTrustStoreSSLSocketFactory(< your_jks_file_path> );
109
- io.jackey . JedisPool jedisPool = new io.jackey . JedisPool (new GenericObjectPoolConfig (), < host> ,
110
- < port> , < timeout> , < password> , 0 , true , sslSocketFactory, null , null );
113
+ final SSLSocketFactory sslSocketFactory = createTrustStoreSSLSocketFactory( < your_jks_file_path > );
114
+ io.valkey . JedisPool jedisPool = new io.valkey . JedisPool (new GenericObjectPoolConfig (), < host > ,
115
+ < port > , < timeout > , < password > , 0 , true , sslSocketFactory, null , null );
111
116
112
- try (io.jackey . Jedis jedis = pool. getResource()) {
117
+ try (io.valkey . Jedis jedis = pool. getResource()) {
113
118
jedis. set(" key" , " value" );
114
119
System . out. println(jedis. get(" key" ));
115
120
} catch (Exception e) {
0 commit comments