mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
remove redis as caching is no longer needed now
This commit is contained in:
@@ -12,12 +12,6 @@ import io.smallrye.config.WithDefault;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
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;
|
||||
|
||||
/**
|
||||
* CommaFeed configuration
|
||||
@@ -92,11 +86,6 @@ public interface CommaFeedConfiguration {
|
||||
*/
|
||||
Websocket websocket();
|
||||
|
||||
/**
|
||||
* Redis settings to enable caching. This is only really useful on instances with a lot of users.
|
||||
*/
|
||||
Redis redis();
|
||||
|
||||
interface FeedRefresh {
|
||||
/**
|
||||
* Amount of time CommaFeed will wait before refreshing the same feed.
|
||||
@@ -230,47 +219,4 @@ public interface CommaFeedConfiguration {
|
||||
Duration treeReloadInterval();
|
||||
}
|
||||
|
||||
interface Redis {
|
||||
|
||||
Optional<String> host();
|
||||
|
||||
@WithDefault("" + Protocol.DEFAULT_PORT)
|
||||
int port();
|
||||
|
||||
/**
|
||||
* Username is only required when using Redis ACLs
|
||||
*/
|
||||
Optional<String> username();
|
||||
|
||||
Optional<String> password();
|
||||
|
||||
@WithDefault("" + Protocol.DEFAULT_TIMEOUT)
|
||||
int timeout();
|
||||
|
||||
@WithDefault("" + Protocol.DEFAULT_DATABASE)
|
||||
int database();
|
||||
|
||||
@WithDefault("500")
|
||||
int maxTotal();
|
||||
|
||||
default JedisPool build() {
|
||||
Optional<String> host = host();
|
||||
if (host.isEmpty()) {
|
||||
throw new IllegalStateException("Redis host is required");
|
||||
}
|
||||
|
||||
JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
poolConfig.setMaxTotal(maxTotal());
|
||||
|
||||
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder()
|
||||
.user(username().orElse(null))
|
||||
.password(password().orElse(null))
|
||||
.timeoutMillis(timeout())
|
||||
.database(database())
|
||||
.build();
|
||||
|
||||
return new JedisPool(poolConfig, new HostAndPort(host.get(), port()), clientConfig);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user