Skip to content

Commit

Permalink
Periodically clear faled cache items
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Jul 18, 2023
1 parent 88702f0 commit b6aea67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/jasper/component/WebScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

import static com.fasterxml.jackson.databind.node.TextNode.valueOf;
import static jasper.domain.proj.Tag.hasMedia;
Expand Down Expand Up @@ -681,6 +682,11 @@ public void drainAsyncScrape() {
scraping.clear();
}

@Scheduled(fixedDelay = 5, timeUnit = TimeUnit.MINUTES)
public void clearFailed() {
webRepository.deleteAllByDataIsNullAndMimeIsNull();
}

@Timed(value = "jasper.webscrape")
public Web fetch(String url) {
url = fixUrl(url);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/jasper/repository/WebRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

@Repository
public interface WebRepository extends JpaRepository<Web, String> {
void deleteAllByDataIsNullAndMimeIsNull();
}

0 comments on commit b6aea67

Please sign in to comment.