mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
Make database optional
This commit is contained in:
2 files changed
+9
-4
No files matched your search
@@ -11,7 +11,7 @@ public final class RedisCredentials {
|
|||||||
@Setting private @NonNull String host = "localhost";
|
@Setting private @NonNull String host = "localhost";
|
||||||
@Setting private @Nullable String password = "";
|
@Setting private @Nullable String password = "";
|
||||||
@Setting private int port = 6379;
|
@Setting private int port = 6379;
|
||||||
@Setting private int database = 0;
|
@Setting private @Nullable Integer database = null;
|
||||||
|
|
||||||
public @NonNull String host() {
|
public @NonNull String host() {
|
||||||
return this.host;
|
return this.host;
|
||||||
@@ -25,7 +25,7 @@ public final class RedisCredentials {
|
|||||||
return this.port;
|
return this.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int database() {
|
public @Nullable Integer database() {
|
||||||
return this.database;
|
return this.database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -43,8 +43,13 @@ public class RedisMessageService implements MessageService {
|
|||||||
public RedisMessageService(final @NonNull CarbonChat carbonChat, final @NonNull RedisCredentials credentials) {
|
public RedisMessageService(final @NonNull CarbonChat carbonChat, final @NonNull RedisCredentials credentials) {
|
||||||
this.carbonChat = carbonChat;
|
this.carbonChat = carbonChat;
|
||||||
|
|
||||||
final RedisURI.Builder builder = RedisURI.Builder.redis(credentials.host(), credentials.port())
|
final RedisURI.Builder builder = RedisURI.Builder.redis(credentials.host(), credentials.port());
|
||||||
.withDatabase(credentials.database());
|
|
||||||
|
final Integer database = credentials.database();
|
||||||
|
|
||||||
|
if (database != null) {
|
||||||
|
builder.withDatabase(database);
|
||||||
|
}
|
||||||
|
|
||||||
final String password = credentials.password();
|
final String password = credentials.password();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user