mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
initial entry caching implementation
This commit is contained in:
@@ -20,6 +20,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.commafeed.backend.MetricsBean;
|
||||
import com.commafeed.backend.cache.CacheService;
|
||||
import com.commafeed.backend.dao.FeedDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryDAO;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||
@@ -62,6 +63,9 @@ public class FeedRefreshUpdater {
|
||||
@Inject
|
||||
FeedEntryDAO feedEntryDAO;
|
||||
|
||||
@Inject
|
||||
CacheService cache;
|
||||
|
||||
private ThreadPoolExecutor pool;
|
||||
private Striped<Lock> locks;
|
||||
private LinkedBlockingDeque<Runnable> queue;
|
||||
@@ -167,7 +171,13 @@ public class FeedRefreshUpdater {
|
||||
try {
|
||||
locked = lock.tryLock(1, TimeUnit.MINUTES);
|
||||
if (locked) {
|
||||
feedUpdateService.updateEntry(feed, entry, subscriptions);
|
||||
if (!cache.hasFeedEntry(feed, entry)) {
|
||||
log.info("cache miss for {}", entry.getUrl());
|
||||
feedUpdateService.updateEntry(feed, entry, subscriptions);
|
||||
cache.putFeedEntry(feed, entry);
|
||||
} else {
|
||||
log.info("cache hit for {}", entry.getUrl());
|
||||
}
|
||||
success = true;
|
||||
} else {
|
||||
log.error("lock timeout for " + feed.getUrl() + " - " + key);
|
||||
|
||||
Reference in New Issue
Block a user