forked from Archives/Athou_commafeed
enable redis connections with ACLs
This commit is contained in:
@@ -125,6 +125,8 @@ logging:
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
# username is only required when using ACLs
|
||||
username:
|
||||
password:
|
||||
timeout: 2000
|
||||
database: 0
|
||||
|
||||
@@ -130,6 +130,8 @@ logging:
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
# username is only required when using ACLs
|
||||
username:
|
||||
password:
|
||||
timeout: 2000
|
||||
database: 0
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>com.commafeed.CommaFeedApplication</mainClass>
|
||||
@@ -387,7 +387,7 @@
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<version>4.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
|
||||
@@ -1,27 +1,53 @@
|
||||
package com.commafeed.backend.cache;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import redis.clients.jedis.DefaultJedisClientConfig;
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
import redis.clients.jedis.JedisClientConfig;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.Protocol;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class RedisPoolFactory {
|
||||
private final String host = "localhost";
|
||||
private final int port = Protocol.DEFAULT_PORT;
|
||||
private String password;
|
||||
private final int timeout = Protocol.DEFAULT_TIMEOUT;
|
||||
private final int database = Protocol.DEFAULT_DATABASE;
|
||||
|
||||
private final int maxTotal = 500;
|
||||
@JsonProperty
|
||||
private String host = "localhost";
|
||||
|
||||
@JsonProperty
|
||||
private int port = Protocol.DEFAULT_PORT;
|
||||
|
||||
@JsonProperty
|
||||
private String username;
|
||||
|
||||
@JsonProperty
|
||||
private String password;
|
||||
|
||||
@JsonProperty
|
||||
private int timeout = Protocol.DEFAULT_TIMEOUT;
|
||||
|
||||
@JsonProperty
|
||||
private int database = Protocol.DEFAULT_DATABASE;
|
||||
|
||||
@JsonProperty
|
||||
private int maxTotal = 500;
|
||||
|
||||
public JedisPool build() {
|
||||
JedisPoolConfig config = new JedisPoolConfig();
|
||||
config.setMaxTotal(maxTotal);
|
||||
JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
poolConfig.setMaxTotal(maxTotal);
|
||||
|
||||
return new JedisPool(config, host, port, timeout, StringUtils.trimToNull(password), database);
|
||||
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder()
|
||||
.user(username)
|
||||
.password(password)
|
||||
.timeoutMillis(timeout)
|
||||
.database(database)
|
||||
.build();
|
||||
|
||||
return new JedisPool(poolConfig, new HostAndPort(host, port), clientConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user