mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
cache config
This commit is contained in:
@@ -18,6 +18,7 @@ app:
|
|||||||
crawlingPaused: false
|
crawlingPaused: false
|
||||||
keepStatusDays: 0
|
keepStatusDays: 0
|
||||||
refreshIntervalMinutes: 5
|
refreshIntervalMinutes: 5
|
||||||
|
cache: noop
|
||||||
announcement:
|
announcement:
|
||||||
|
|
||||||
authenticationCachePolicy: maximumSize=10000, expireAfterAccess=10m
|
authenticationCachePolicy: maximumSize=10000, expireAfterAccess=10m
|
||||||
|
|||||||
@@ -10,12 +10,16 @@ import io.dropwizard.setup.Environment;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
|
||||||
import com.codahale.metrics.MetricRegistry;
|
import com.codahale.metrics.MetricRegistry;
|
||||||
|
import com.commafeed.CommaFeedConfiguration.CacheType;
|
||||||
import com.commafeed.backend.HttpGetter;
|
import com.commafeed.backend.HttpGetter;
|
||||||
import com.commafeed.backend.cache.CacheService;
|
import com.commafeed.backend.cache.CacheService;
|
||||||
import com.commafeed.backend.cache.NoopCacheService;
|
import com.commafeed.backend.cache.NoopCacheService;
|
||||||
|
import com.commafeed.backend.cache.RedisCacheService;
|
||||||
import com.commafeed.backend.dao.FeedCategoryDAO;
|
import com.commafeed.backend.dao.FeedCategoryDAO;
|
||||||
import com.commafeed.backend.dao.FeedDAO;
|
import com.commafeed.backend.dao.FeedDAO;
|
||||||
import com.commafeed.backend.dao.FeedEntryContentDAO;
|
import com.commafeed.backend.dao.FeedEntryContentDAO;
|
||||||
@@ -68,6 +72,7 @@ import com.commafeed.frontend.resource.ServerREST;
|
|||||||
import com.commafeed.frontend.resource.UserREST;
|
import com.commafeed.frontend.resource.UserREST;
|
||||||
import com.commafeed.frontend.servlet.NextUnreadServlet;
|
import com.commafeed.frontend.servlet.NextUnreadServlet;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
|
public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
|
||||||
|
|
||||||
public static final String USERNAME_ADMIN = "admin";
|
public static final String USERNAME_ADMIN = "admin";
|
||||||
@@ -106,8 +111,9 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
|
|||||||
MetricRegistry metrics = environment.metrics();
|
MetricRegistry metrics = environment.metrics();
|
||||||
SessionFactory sessionFactory = hibernateBundle.getSessionFactory();
|
SessionFactory sessionFactory = hibernateBundle.getSessionFactory();
|
||||||
|
|
||||||
// TODO select cache service at runtime from config
|
CacheService cacheService = config.getApplicationSettings().getCache() == CacheType.NOOP ? new NoopCacheService()
|
||||||
CacheService cacheService = new NoopCacheService();
|
: new RedisCacheService();
|
||||||
|
log.info("using cache {}", cacheService.getClass());
|
||||||
|
|
||||||
FeedCategoryDAO feedCategoryDAO = new FeedCategoryDAO(sessionFactory);
|
FeedCategoryDAO feedCategoryDAO = new FeedCategoryDAO(sessionFactory);
|
||||||
FeedDAO feedDAO = new FeedDAO(sessionFactory);
|
FeedDAO feedDAO = new FeedDAO(sessionFactory);
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ import com.google.common.cache.CacheBuilderSpec;
|
|||||||
@Getter
|
@Getter
|
||||||
public class CommaFeedConfiguration extends Configuration {
|
public class CommaFeedConfiguration extends Configuration {
|
||||||
|
|
||||||
|
public static enum CacheType {
|
||||||
|
NOOP, REDIS
|
||||||
|
}
|
||||||
|
|
||||||
@Valid
|
@Valid
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonProperty("database")
|
@JsonProperty("database")
|
||||||
@@ -92,6 +96,9 @@ public class CommaFeedConfiguration extends Configuration {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private int refreshIntervalMinutes;
|
private int refreshIntervalMinutes;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private CacheType cache;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String announcement;
|
private String announcement;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user