Browse Source

[缓存][修改]:缓存先rollback

release_toaliyun_real
Stormeye Wu 6 years ago
parent
commit
60491429ea
13 changed files with 1 additions and 212 deletions
  1. +0
    -20
      mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java
  2. +0
    -19
      mallinkBApi/src/main/java/com/iformall/config/RedisConfig.java
  3. +0
    -19
      mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java
  4. +0
    -19
      mallinkCallback/src/main/java/com/iformall/config/RedisConfig.java
  5. +0
    -18
      mallinkMQConsumer/src/main/java/com/iformall/config/RedisConfig.java
  6. +0
    -18
      mallinkPosApi/src/main/java/com/iformall/config/RedisConfig.java
  7. +0
    -19
      mallinkSchedule/src/main/java/com/iformall/config/RedisConfig.java
  8. +0
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java
  9. +0
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java
  10. +0
    -39
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  11. +1
    -1
      mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml
  12. +0
    -19
      mallinkSysAdmin/src/main/java/com/iformall/config/RedisConfig.java
  13. +0
    -19
      mallinkWebSocketServer/src/main/java/com/iformall/config/RedisConfig.java

+ 0
- 20
mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -162,22 +160,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}


@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

}

+ 0
- 19
mallinkBApi/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -124,21 +122,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

}

+ 0
- 19
mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,12 +1,10 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponCVo;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -142,21 +140,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

}

+ 0
- 19
mallinkCallback/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -162,21 +160,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

}

+ 0
- 18
mallinkMQConsumer/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -146,20 +144,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}
}

+ 0
- 18
mallinkPosApi/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -124,20 +122,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}
}

+ 0
- 19
mallinkSchedule/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -147,21 +145,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

}

+ 0
- 1
mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java View File

@@ -7,7 +7,6 @@ import com.iformall.domain.po.WxTopic;
import com.iformall.domain.vo.WxCouponCVo;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.domain.po.WxCouponChannel;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;

public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, String> {


+ 0
- 1
mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java View File

@@ -5,7 +5,6 @@ import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxTopic;
import com.iformall.domain.vo.WxCouponCVo;
import com.iformall.domain.vo.WxCouponStatisVo;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;
import com.iformall.domain.po.WxCoupon;



+ 0
- 39
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java View File

@@ -21,13 +21,9 @@ import com.iformall.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

@Service
@@ -50,9 +46,6 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
QrCodeService qrCodeService;
@Autowired
WxCardInfoMapper wxCardInfoMapper;
@Autowired
@Qualifier("couponChannelRedisTemplate")
RedisTemplate<String, PageInfo<WxCouponChannelVo>> cdRedisTemplate;

/**
* B端业务端
@@ -118,23 +111,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
record.setUpdateDate(new Date());
wxCouponChannelMapper.updateByPrimaryKeySelective(record);
}

//清除缓存
clearCache(record.getTenantId());
return new ResultData();
}

/**
* 清除c端首页卷列表缓存
* @param tenantId
*/
public void clearCache(String tenantId){
for (int i = 1; i <=20 ; i++) {
String key = "couponChannelList_"+tenantId+"_" + i + ":";
cdRedisTemplate.delete(key);
}
}

@Override
public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) {
List<WxCouponChannelAddVo> errorList = new ArrayList<>();
@@ -305,24 +284,6 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
*/
@Override
public PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) {
PageInfo<WxCouponChannelVo> pageInfo;
//首页走缓存
if(EnumTargetAd.LIST.getCode().equals(record.getTargetAd()) && new Integer(6).equals(pageSize) && pageIndex.intValue() <=20 ) {
logger.info("---------chache");
String key = "couponChannelList_"+record.getTenantId()+"_" + pageIndex + ":";
ValueOperations<String, PageInfo<WxCouponChannelVo>> operations = cdRedisTemplate.opsForValue();
boolean hasKey = cdRedisTemplate.hasKey(key);
if (hasKey) {
pageInfo = operations.get(key);
logger.info("---------get:{}",pageInfo.getList().size());
}else{
pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record));
}
//插入缓存
operations.set(key, pageInfo, 3600, TimeUnit.SECONDS);
return pageInfo;
}

return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record));
}



+ 1
- 1
mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml View File

@@ -180,7 +180,7 @@

</resultMap>

<select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap" useCache="true">
<select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
select <include refid="CouponChannelVoColumns" />
from wx_coupon_channel cc
left join wx_coupon c on cc.coupon_id = c.id


+ 0
- 19
mallinkSysAdmin/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -162,21 +160,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

}

+ 0
- 19
mallinkWebSocketServer/src/main/java/com/iformall/config/RedisConfig.java View File

@@ -1,11 +1,9 @@
package com.iformall.config;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -146,21 +144,4 @@ public class RedisConfig extends CachingConfigurerSupport {
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

}

Loading…
Cancel
Save