Skip to content

Instantly share code, notes, and snippets.

@sizovs
Created September 19, 2014 13:50
Show Gist options
  • Save sizovs/6abeddabbf08bb9c95f6 to your computer and use it in GitHub Desktop.
Save sizovs/6abeddabbf08bb9c95f6 to your computer and use it in GitHub Desktop.
@Repository
class DefaultDailyQuestionTemplateRepository implements DailyQuestionTemplateRepository {
private static final String DAILY_QUESTION_TEMPLATE_CACHE = "dailyQuestionTemplate";
private final DailyQuestionTemplateDAO dailyQuestionTemplateDAO;
@Cacheable(DAILY_QUESTION_TEMPLATE_CACHE)
@Override
public DailyQuestionTemplate get(DailyQuestionTemplateId dailyQuestionTemplateId) {
DailyQuestionTemplate dailyQuestionTemplate = dailyQuestionTemplateDAO.getById(dailyQuestionTemplateId);
if (dailyQuestionTemplate == null) {
throw new EntityDoesNotExistException(dailyQuestionTemplateId);
}
return dailyQuestionTemplate;
}
@Configuration
static class CacheConfiguration {
@Autowired
@ConfigurableBean(value = "daily_question_template_cache")
IConfProperty<DailyQuestionTemplateCacheConfiguration> cacheConfiguration;
@Bean
GuavaCacheManagerFactoryBean dailyQuestionTemplateCacheManager(Ticker ticker) {
return new GuavaCacheManagerFactoryBean(DAILY_QUESTION_TEMPLATE_CACHE, cacheConfiguration, ticker);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment