Search in sources :

Example 1 with UrlInfo

use of com.github.liuweijw.business.wechat.domain.UrlInfo in project fw-cloud-framework by liuweijw.

the class UrlInfoServiceImpl method findByUuid.

@Override
public UrlInfo findByUuid(String uuid) {
    if (StringHelper.isBlank(uuid))
        return null;
    QUrlInfo qUrlInfo = QUrlInfo.urlInfo;
    UrlInfo dbUrlInfo = this.queryFactory.selectFrom(qUrlInfo).where(qUrlInfo.uuid.eq(uuid)).fetchFirst();
    return dbUrlInfo;
}
Also used : QUrlInfo(com.github.liuweijw.business.wechat.domain.QUrlInfo) QUrlInfo(com.github.liuweijw.business.wechat.domain.QUrlInfo) UrlInfo(com.github.liuweijw.business.wechat.domain.UrlInfo)

Example 2 with UrlInfo

use of com.github.liuweijw.business.wechat.domain.UrlInfo in project fw-cloud-framework by liuweijw.

the class UrlInfoServiceImpl method cacheUrlInfo.

@Override
public void cacheUrlInfo(UrlInfoBean urlInfoBean) {
    try {
        log.info("设置缓存微信UrlInfo[uuid]:" + urlInfoBean.getUuid());
        cacheManager.getCache(WECHAT_URL_INFO).put(urlInfoBean.getUuid(), urlInfoBean);
    } catch (Exception e) {
        log.info("设置缓存微信UrlInfo[uuid]:" + urlInfoBean.getUuid() + "失败,入库保障");
        UrlInfo urlInfo = new UrlInfo();
        urlInfo.setTime(System.currentTimeMillis());
        urlInfo.setUrl(urlInfoBean.getUrl());
        urlInfo.setUuid(urlInfoBean.getUuid());
        this.saveOrUpdate(urlInfo);
    }
}
Also used : QUrlInfo(com.github.liuweijw.business.wechat.domain.QUrlInfo) UrlInfo(com.github.liuweijw.business.wechat.domain.UrlInfo)

Example 3 with UrlInfo

use of com.github.liuweijw.business.wechat.domain.UrlInfo in project fw-cloud-framework by liuweijw.

the class UrlInfoServiceImpl method findFromCacheByUuid.

@Override
public UrlInfoBean findFromCacheByUuid(String uuid) {
    log.info("从缓存查询微信UrlInfo[uuid]:" + uuid);
    Cache cache = cacheManager.getCache(WECHAT_URL_INFO);
    Optional<UrlInfoBean> optional = Optional.ofNullable(cache.get(uuid, UrlInfoBean.class));
    if (optional.isPresent()) {
        log.info("从缓存查询微信UrlInfo[uuid]:" + uuid + "查询成功");
        cache.evict(uuid);
        return optional.get();
    }
    log.error("从缓存查询微信UrlInfo[uuid]:" + uuid + "未查询到");
    UrlInfo dbUserinfo = findByUuid(uuid);
    if (null == dbUserinfo) {
        log.error("从db查询微信UrlInfo[uuid]:" + uuid + "未查询到");
        return new UrlInfoBean();
    }
    log.info("从db查询微信UrlInfo[uuid]:" + uuid + "查询成功");
    return new UrlInfoBean(dbUserinfo.getUuid(), dbUserinfo.getUrl());
}
Also used : UrlInfoBean(com.github.liuweijw.business.wechat.beans.UrlInfoBean) QUrlInfo(com.github.liuweijw.business.wechat.domain.QUrlInfo) UrlInfo(com.github.liuweijw.business.wechat.domain.UrlInfo) Cache(org.springframework.cache.Cache)

Aggregations

QUrlInfo (com.github.liuweijw.business.wechat.domain.QUrlInfo)3 UrlInfo (com.github.liuweijw.business.wechat.domain.UrlInfo)3 UrlInfoBean (com.github.liuweijw.business.wechat.beans.UrlInfoBean)1 Cache (org.springframework.cache.Cache)1