Skip to content

Commit

Permalink
✨ Support configure database for redis (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoDuanLZ authored Jul 30, 2020
1 parent 67f534e commit 25847f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ open class DefaultRedisClientFactory : RedisClientFactory {

protected open fun createRedisClient(host: String, port: Int, property: RedisProperty): RedisClient {
return clients.getOrPut("$host:$port") {
RedisClient.create(RedisURI.Builder.redis(host, port).withPassword(property.password).build())
val database = property.database ?: 0
RedisClient.create(RedisURI.Builder.redis(host, port).withPassword(property.password).withDatabase(database).build())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ data class RedisProperty(
val name: String?,
val host: String,
val port: Int,
val password: String
val password: String,
val database: Int?
)

data class RedisProperties(
Expand Down

0 comments on commit 25847f3

Please sign in to comment.