Search in sources :

Example 1 with CacheExpire

use of com.dimple.framework.config.redis.CacheExpire in project DimpleBlog by martin-chips.

the class DashboardServiceImpl method getLineChartData.

@Override
@Cacheable(value = "DashBoard", key = "'LineChartData'+ #type")
@CacheExpire(expire = 3, type = TimeType.HOURS)
public LineChartData<Long> getLineChartData(String type) {
    LineChartData lineChartData;
    switch(type) {
        case LineChartData.BLOG_LINE:
            lineChartData = getBlogLineChartData();
            break;
        case LineChartData.VISITOR_LINE:
            lineChartData = getVisitorLineChartData();
            break;
        default:
            lineChartData = new LineChartData();
    }
    log.info("get line chart data \n{}", lineChartData);
    return lineChartData;
}
Also used : LineChartData(com.dimple.project.home.domain.LineChartData) CacheExpire(com.dimple.framework.config.redis.CacheExpire) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with CacheExpire

use of com.dimple.framework.config.redis.CacheExpire in project DimpleBlog by martin-chips.

the class ConfigServiceImpl method selectConfigByConfigKey.

@Override
@Cacheable(value = CacheConstants.CACHE_NAME_BACKEND_CONFIG, key = "#key")
@CacheExpire(expire = 5, type = TimeType.HOURS)
public <T> T selectConfigByConfigKey(String key, Class<T> tClass) {
    Config config = new Config();
    config.setConfigKey(key);
    Config retConfig = configMapper.selectConfig(config);
    if (retConfig == null) {
        throw new CustomException("Can not get config by key  " + key);
    }
    return JSON.parseObject(retConfig.getConfigValue(), tClass);
}
Also used : Config(com.dimple.project.system.domain.Config) CustomException(com.dimple.common.exception.CustomException) CacheExpire(com.dimple.framework.config.redis.CacheExpire) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 3 with CacheExpire

use of com.dimple.framework.config.redis.CacheExpire in project DimpleBlog by martin-chips.

the class FrontServiceImpl method selectBlogDetailById.

@Override
@Cacheable(value = CacheConstants.CACHE_NAME_FRONT_BLOG_ITEM, key = "'BlogId:' +#id")
@CacheExpire(expire = 1, type = TimeType.MINUTES)
public Blog selectBlogDetailById(Long id) {
    Blog blog = frontMapper.selectBlogDetailById(id);
    // get all comment
    blog.setCommentList(selectCommentListByPageId(id));
    return blog;
}
Also used : Blog(com.dimple.project.blog.domain.Blog) CacheExpire(com.dimple.framework.config.redis.CacheExpire) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

CacheExpire (com.dimple.framework.config.redis.CacheExpire)3 Cacheable (org.springframework.cache.annotation.Cacheable)3 CustomException (com.dimple.common.exception.CustomException)1 Blog (com.dimple.project.blog.domain.Blog)1 LineChartData (com.dimple.project.home.domain.LineChartData)1 Config (com.dimple.project.system.domain.Config)1