File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
articles/azure-cache-for-redis Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -127,9 +127,10 @@ Clone the repo [Java quickstart](https://github.com/Azure-Samples/azure-cache-re
127
127
128
128
String cacheHostname = System.getenv("REDIS_CACHE_HOSTNAME");
129
129
String username = System.getenv("USER_NAME");
130
+ int port = Integer.parseInt(System.getenv().getOrDefault("REDIS_CACHE_PORT", "6380"));
130
131
131
132
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key.
132
- Jedis jedis = new Jedis(cacheHostname, 6380 , DefaultJedisClientConfig.builder()
133
+ Jedis jedis = new Jedis(cacheHostname, port , DefaultJedisClientConfig.builder()
133
134
.password(token) // Microsoft Entra access token as password is required.
134
135
.user(username) // Username is Required
135
136
.ssl(useSsl) // SSL Connection is Required
@@ -180,9 +181,10 @@ Clone the repo [Java quickstart](https://github.com/Azure-Samples/azure-cache-re
180
181
boolean useSsl = true;
181
182
String cacheHostname = System.getenv("REDIS_CACHE_HOSTNAME");
182
183
String cachekey = System.getenv("REDIS_CACHE_KEY");
184
+ int port = Integer.parseInt(System.getenv().getOrDefault("REDIS_CACHE_PORT", "6380"));
183
185
184
186
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key.
185
- Jedis jedis = new Jedis(cacheHostname, 6380 , DefaultJedisClientConfig.builder()
187
+ Jedis jedis = new Jedis(cacheHostname, port , DefaultJedisClientConfig.builder()
186
188
.password(cachekey)
187
189
.ssl(useSsl)
188
190
.build());
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ This quickstart uses the Maven archetype feature to generate the scaffolding for
164
164
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key
165
165
Config redissonconfig = new Config ();
166
166
redissonconfig. useSingleServer()
167
- .setAddress(String . format(" rediss://%s:6380 " , System . getenv(" REDIS_CACHE_HOSTNAME" )))
167
+ .setAddress(String . format(" rediss://%s:%s " , System . getenv(" REDIS_CACHE_HOSTNAME" ), System . getenv( " REDIS_CACHE_PORT " )))
168
168
.setUsername(System . getenv(" USER_NAME" )) // (Required) Username is Object ID of your managed identity or service principal
169
169
.setPassword(token); // Microsoft Entra access token as password is required.
170
170
return redissonconfig;
@@ -228,7 +228,7 @@ This quickstart uses the Maven archetype feature to generate the scaffolding for
228
228
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key
229
229
Config redissonconfig = new Config ();
230
230
redissonconfig. useSingleServer(). setPassword(System . getenv(" REDIS_CACHE_KEY" ))
231
- .setAddress(String . format(" rediss://%s:6380 " , System . getenv(" REDIS_CACHE_HOSTNAME" )));
231
+ .setAddress(String . format(" rediss://%s:%s " , System . getenv(" REDIS_CACHE_HOSTNAME" ), System . getenv( " REDIS_CACHE_PORT " )));
232
232
return redissonconfig;
233
233
}
234
234
}
You can’t perform that action at this time.
0 commit comments