Skip to content

Commit

Permalink
[CHORE] Simple caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Oct 31, 2024
1 parent 1dd78ac commit 87e3fc0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;

@SpringBootApplication
@EnableCaching
public class DictionaryApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.harvard.dbmi.avillach.dictionary.concept.model.ContinuousConcept;
import edu.harvard.dbmi.avillach.dictionary.filter.Filter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

Expand All @@ -26,6 +27,7 @@ public ConceptService(ConceptRepository conceptRepository, ConceptDecoratorServi
this.conceptDecoratorService = conceptDecoratorService;
}

@Cacheable("concepts")
public List<Concept> listConcepts(Filter filter, Pageable page) {
return conceptRepository.getConcepts(filter, page);
}
Expand All @@ -40,6 +42,7 @@ public List<Concept> listDetailedConcepts(Filter filter, Pageable page) {
}).toList();
}

@Cacheable("concepts_count")
public long countConcepts(Filter filter) {
return conceptRepository.countConcepts(filter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.harvard.dbmi.avillach.dictionary.filter.Filter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -17,6 +18,7 @@ public FacetService(FacetRepository repository) {
this.repository = repository;
}

@Cacheable("facets")
public List<FacetCategory> getFacets(Filter filter) {
return repository.getFacets(filter);
}
Expand Down

0 comments on commit 87e3fc0

Please sign in to comment.