Skip to content

Commit

Permalink
remove redis as caching is no longer needed now
Browse files Browse the repository at this point in the history
  • Loading branch information
Athou committed Aug 12, 2024
1 parent 9f083b3 commit a70cf97
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 411 deletions.
3 changes: 1 addition & 2 deletions commafeed-client/src/pages/admin/MetricsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const shownMeters: Record<string, string> = {
"com.commafeed.backend.feed.FeedRefreshEngine.refill": "Feed queue refill rate",
"com.commafeed.backend.feed.FeedRefreshWorker.feedFetched": "Feed fetching rate",
"com.commafeed.backend.feed.FeedRefreshUpdater.feedUpdated": "Feed update rate",
"com.commafeed.backend.feed.FeedRefreshUpdater.entryCacheHit": "Entry cache hit rate",
"com.commafeed.backend.feed.FeedRefreshUpdater.entryCacheMiss": "Entry cache miss rate",
"com.commafeed.backend.feed.FeedRefreshUpdater.entryInserted": "Entries inserted",
"com.commafeed.backend.service.db.DatabaseCleaningService.entriesDeleted": "Entries deleted",
}

Expand Down
1 change: 0 additions & 1 deletion commafeed-server/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ TODO

MVP:

- remove redis, not useful anymore
- update readme
- update docker readme
- update release notes (+ mention h2 migration has been removed, upgrade to last 4.x is required)
Expand Down
5 changes: 0 additions & 5 deletions commafeed-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,6 @@
<artifactId>passay</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>5.1.4</version>
</dependency>

<dependency>
<groupId>com.rometools</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -230,47 +219,4 @@ interface Websocket {
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);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
package com.commafeed;

import com.codahale.metrics.MetricRegistry;
import com.commafeed.CommaFeedConfiguration.Redis;
import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.cache.NoopCacheService;
import com.commafeed.backend.cache.RedisCacheService;

import jakarta.enterprise.inject.Produces;
import jakarta.inject.Singleton;

@Singleton
public class CommaFeedProducers {

@Produces
@Singleton
public CacheService cacheService(CommaFeedConfiguration config) {
Redis redis = config.redis();
if (redis.host().isEmpty()) {
return new NoopCacheService();
}

return new RedisCacheService(redis.build());
}

@Produces
@Singleton
public MetricRegistry metricRegistry() {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a70cf97

Please sign in to comment.