Created
September 19, 2014 13:50
-
-
Save sizovs/6abeddabbf08bb9c95f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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