mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
Add redis password support
This commit is contained in:
1 parent
fd542a7f5e
commit
785fabcd3c
2 files changed
+9
-4
No files matched your search
@@ -26,14 +26,18 @@ public class RedisManager {
|
|||||||
public RedisManager(CarbonChat carbonChat) {
|
public RedisManager(CarbonChat carbonChat) {
|
||||||
|
|
||||||
String host = carbonChat.getConfig().getString("redis.host");
|
String host = carbonChat.getConfig().getString("redis.host");
|
||||||
|
String password = carbonChat.getConfig().getString("redis.password");
|
||||||
int port = carbonChat.getConfig().getInt("redis.port");
|
int port = carbonChat.getConfig().getInt("redis.port");
|
||||||
int database = carbonChat.getConfig().getInt("redis.database");
|
int database = carbonChat.getConfig().getInt("redis.database");
|
||||||
|
|
||||||
RedisURI uri = RedisURI.Builder.redis(host, port)
|
RedisURI.Builder builder = RedisURI.Builder.redis(host, port)
|
||||||
.withDatabase(database)
|
.withDatabase(database);
|
||||||
.build();
|
|
||||||
|
|
||||||
this.client = RedisClient.create(uri);
|
if (password != null) {
|
||||||
|
builder.withPassword(password.toCharArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.client = RedisClient.create(builder.build());
|
||||||
this.connection = client.connectPubSub();
|
this.connection = client.connectPubSub();
|
||||||
this.sync = connection.sync();
|
this.sync = connection.sync();
|
||||||
|
|
||||||
|
|||||||
@@ -121,4 +121,5 @@ redis:
|
|||||||
enabled: false
|
enabled: false
|
||||||
host: 'localhost'
|
host: 'localhost'
|
||||||
port: 6379
|
port: 6379
|
||||||
|
#password: 'password'
|
||||||
database: 0
|
database: 0
|
||||||
Reference in new issue
Block a user