提交 a267600f 编写于 作者: 爱吃血肠's avatar 爱吃血肠

删除无用代码

上级 7f488679
package com.yingjun.ssm.cache;
import com.yingjun.ssm.util.ProtoStuffSerializerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
/**
* redis缓存
......@@ -21,110 +14,5 @@ import java.util.Set;
public class RedisCache {
// public final static String CAHCENAME="cache";//缓存名
// public final static int CAHCETIME=60;//默认缓存时间
//
// @Autowired
// private RedisTemplate<String, String> redisTemplate;
//
// public <T> boolean putCache(String key, T obj) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serialize(obj);
// boolean result = redisTemplate.execute(new RedisCallback<Boolean>() {
// @Override
// public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
// return connection.setNX(bkey, bvalue);
// }
// });
// return result;
// }
//
// public <T> void putCacheWithExpireTime(String key, T obj, final long expireTime) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serialize(obj);
// redisTemplate.execute(new RedisCallback<Boolean>() {
// @Override
// public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
// connection.setEx(bkey, expireTime, bvalue);
// return true;
// }
// });
// }
//
// public <T> boolean putListCache(String key, List<T> objList) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serializeList(objList);
// boolean result = redisTemplate.execute(new RedisCallback<Boolean>() {
// @Override
// public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
// return connection.setNX(bkey, bvalue);
// }
// });
// return result;
// }
//
// public <T> boolean putListCacheWithExpireTime(String key, List<T> objList, final long expireTime) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serializeList(objList);
// boolean result = redisTemplate.execute(new RedisCallback<Boolean>() {
// @Override
// public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
// connection.setEx(bkey, expireTime, bvalue);
// return true;
// }
// });
// return result;
// }
//
// public <T> T getCache(final String key, Class<T> targetClass) {
// byte[] result = redisTemplate.execute(new RedisCallback<byte[]>() {
// @Override
// public byte[] doInRedis(RedisConnection connection) throws DataAccessException {
// return connection.get(key.getBytes());
// }
// });
// if (result == null) {
// return null;
// }
// return ProtoStuffSerializerUtil.deserialize(result, targetClass);
// }
//
// public <T> List<T> getListCache(final String key, Class<T> targetClass) {
// byte[] result = redisTemplate.execute(new RedisCallback<byte[]>() {
// @Override
// public byte[] doInRedis(RedisConnection connection) throws DataAccessException {
// return connection.get(key.getBytes());
// }
// });
// if (result == null) {
// return null;
// }
// return ProtoStuffSerializerUtil.deserializeList(result, targetClass);
// }
//
// /**
// * 精确删除key
// *
// * @param key
// */
// public void deleteCache(String key) {
// redisTemplate.delete(key);
// }
//
// /**
// * 模糊删除key
// *
// * @param pattern
// */
// public void deleteCacheWithPattern(String pattern) {
// Set<String> keys = redisTemplate.keys(pattern);
// redisTemplate.delete(keys);
// }
//
// /**
// * 清空所有缓存
// */
// public void clearCache() {
// deleteCacheWithPattern(RedisCache.CAHCENAME+"|*");
// }
}
package com.yingjun.ssm.cache;
import com.yingjun.ssm.util.ProtoStuffSerializerUtil;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPool;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
......@@ -22,103 +15,4 @@ import java.util.Set;
*/
@Component
public class RedisClusterCache {
// public final static String CAHCENAME="cache";//缓存名
// public final static int CAHCETIME=60;//默认缓存时间
//
// //@Autowired
// private JedisCluster jedisCluster;
//
//
// public <T> void putCache(String key, T obj) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serialize(obj);
// jedisCluster.set(bkey,bvalue);
// }
//
// public <T> void putCacheWithExpireTime(String key, T obj, int expireTime) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serialize(obj);
// jedisCluster.setex(bkey, expireTime, bvalue);
// }
//
// public <T> void putListCache(String key, List<T> objList) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serializeList(objList);
// jedisCluster.set(bkey,bvalue);
// }
//
// public <T> void putListCacheWithExpireTime(String key, List<T> objList, int expireTime) {
// final byte[] bkey = key.getBytes();
// final byte[] bvalue = ProtoStuffSerializerUtil.serializeList(objList);
// jedisCluster.setex(bkey, expireTime, bvalue);
// }
//
// public <T> T getCache(final String key, Class<T> targetClass) {
// byte[] result =jedisCluster.get(key.getBytes());
// if (result == null) {
// return null;
// }
// return ProtoStuffSerializerUtil.deserialize(result, targetClass);
// }
//
// public <T> List<T> getListCache(String key, Class<T> targetClass) {
// byte[] result =jedisCluster.get(key.getBytes());
// if (result == null) {
// return null;
// }
// return ProtoStuffSerializerUtil.deserializeList(result, targetClass);
// }
//
// /**
// * 精确删除key
// *
// * @param key
// */
// public void deleteCache(String key) {
// jedisCluster.del(key);
// }
//
// /**
// * 模糊删除key
// *
// * @param pattern
// */
// public void deleteCacheWithPattern(String pattern) {
// Set<String> keys =this.keys(pattern);
// for(String key:keys){
// jedisCluster.del(key);
// }
// }
//
// /**
// * 清空所有缓存
// */
// public void clearCache() {
// deleteCacheWithPattern(RedisClusterCache.CAHCENAME+"|*");
// }
//
// /**
// * 由于JedisCluster没有提供对keys命令的封装,只能自己实现
// * @param pattern
// * @return
// */
// public Set<String> keys(String pattern){
// Set<String> keys = new HashSet<>();
// Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes();
// for(String k : clusterNodes.keySet()){
// JedisPool jp = clusterNodes.get(k);
// Jedis connection = jp.getResource();
// try {
// keys.addAll(connection.keys(pattern));
// } catch(Exception e){
// e.printStackTrace();
// } finally{
// //用完一定要close这个链接!!!
// connection.close();
// }
// }
// return keys;
// }
}
package com.yingjun.ssm.quartz;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yingjun.ssm.cache.RedisCache;
import com.yingjun.ssm.dao.UserDao;
/**
* 业务相关的作业调度
*
字段 允许值 允许的特殊字符
秒 0-59 , - * /
分 0-59 , - * /
小时 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可选) 留空, 1970-2099 , - * /
* 字符代表所有可能的值
/ 字符用来指定数值的增量
L 字符仅被用于天(月)和天(星期)两个子表达式,表示一个月的最后一天或者一个星期的最后一天
6L 可以表示倒数第6天
* @author yingjun
*
*/
@Component
public class BizQuartz {
// private final Logger LOG = LoggerFactory.getLogger(this.getClass());
// @Autowired
// private UserDao userDao;
// @Autowired
// private RedisCache cache;
//
// /**
// * 用户自动加积分
// * 每天9点到17点每过1分钟所有用户加一次积分
// */
// @Scheduled(cron = "0 0/1 9-17 * * ? ")
// public void addUserScore() {
// LOG.info("@Scheduled--------addUserScore()");
// userDao.addScore(10);
// }
// /**
// * 每隔5分钟定时清理缓存
// */
// @Scheduled(cron = "0 0/5 * * * ? ")
// public void cacheClear() {
// LOG.info("@Scheduled-------cacheClear()");
// cache.clearCache();
// }
}
......@@ -12,6 +12,6 @@
<task:annotation-driven />
<context:annotation-config />
<!--<context:component-scan base-package="com.yingjun.ssm.quartz"/> -->
</beans>
......@@ -7,97 +7,5 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--&lt;!&ndash; 缓存的层级&ndash;&gt;-->
<!--<context:component-scan base-package="com.yingjun.ssm.cache" />-->
<!--&lt;!&ndash; 引入redis配置 &ndash;&gt;-->
<!--<context:property-placeholder location="classpath:redis.properties" ignore-unresolvable="true"/>-->
<!--&lt;!&ndash; Redis 配置 &ndash;&gt;-->
<!--<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">-->
<!--<property name="maxTotal" value="${redis.pool.maxTotal}" />-->
<!--<property name="maxIdle" value="${redis.pool.maxIdle}" />-->
<!--<property name="maxWaitMillis" value="${redis.pool.maxWaitMillis}" />-->
<!--<property name="testOnBorrow" value="${redis.pool.testOnBorrow}" />-->
<!--</bean>-->
<!--&lt;!&ndash; JedisCluster 集群高可用配置 &ndash;&gt;-->
<!--&lt;!&ndash;<bean id="jedisCluster" class="redis.clients.jedis.JedisCluster">-->
<!--<constructor-arg index="0">-->
<!--<set>-->
<!--<bean class="redis.clients.jedis.HostAndPort">-->
<!--<constructor-arg index="0" value="${redis.ip1}" />-->
<!--<constructor-arg index="1" value="${redis.port1}" type="int" />-->
<!--</bean>-->
<!--<bean class="redis.clients.jedis.HostAndPort">-->
<!--<constructor-arg index="0" value="${redis.ip2}" />-->
<!--<constructor-arg index="1" value="${redis.port2}" type="int" />-->
<!--</bean>-->
<!--<bean class="redis.clients.jedis.HostAndPort">-->
<!--<constructor-arg index="0" value="${redis.ip3}" />-->
<!--<constructor-arg index="1" value="${redis.port3}" type="int" />-->
<!--</bean>-->
<!--<bean class="redis.clients.jedis.HostAndPort">-->
<!--<constructor-arg index="0" value="${redis.ip4}" />-->
<!--<constructor-arg index="1" value="${redis.port4}" type="int" />-->
<!--</bean>-->
<!--<bean class="redis.clients.jedis.HostAndPort">-->
<!--<constructor-arg index="0" value="${redis.ip5}" />-->
<!--<constructor-arg index="1" value="${redis.port5}" type="int" />-->
<!--</bean>-->
<!--<bean class="redis.clients.jedis.HostAndPort">-->
<!--<constructor-arg index="0" value="${redis.ip6}" />-->
<!--<constructor-arg index="1" value="${redis.port6}" type="int" />-->
<!--</bean>-->
<!--</set>-->
<!--</constructor-arg>-->
<!--<constructor-arg index="1" value="2000" type="int"></constructor-arg>-->
<!--<constructor-arg index="2" value="100" type="int"></constructor-arg>-->
<!--<constructor-arg index="3" ref="jedisPoolConfig"></constructor-arg>-->
<!--</bean>&ndash;&gt;-->
<!--&lt;!&ndash;redis Sentinel主从高可用方案配置 &ndash;&gt;-->
<!--&lt;!&ndash; <bean id="sentinelConfiguration" class="org.springframework.data.redis.connection.RedisSentinelConfiguration">-->
<!--<property name="master">-->
<!--<bean class="org.springframework.data.redis.connection.RedisNode">-->
<!--<property name="name" value="master-1"></property>-->
<!--</bean>-->
<!--</property>-->
<!--<property name="sentinels">-->
<!--<set>-->
<!--<bean class="org.springframework.data.redis.connection.RedisNode">-->
<!--<constructor-arg name="host" value="${sentinel1.ip}"></constructor-arg>-->
<!--<constructor-arg name="port" value="${sentinel1.port}"></constructor-arg>-->
<!--</bean>-->
<!--<bean class="org.springframework.data.redis.connection.RedisNode">-->
<!--<constructor-arg name="host" value="${sentinel2.ip}"></constructor-arg>-->
<!--<constructor-arg name="port" value="${sentinel2.port}"></constructor-arg>-->
<!--</bean>-->
<!--<bean class="org.springframework.data.redis.connection.RedisNode">-->
<!--<constructor-arg name="host" value="${sentinel3.ip}"></constructor-arg>-->
<!--<constructor-arg name="port" value="${sentinel3.port}"></constructor-arg>-->
<!--</bean>-->
<!--</set>-->
<!--</property>-->
<!--</bean>-->
<!--<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:use-pool="true">-->
<!--<property name="password" value="${redis.pass}" />-->
<!--<property name="poolConfig">-->
<!--<ref bean="jedisPoolConfig" />-->
<!--</property>-->
<!--<constructor-arg name="sentinelConfig" ref="sentinelConfiguration" />-->
<!--</bean> &ndash;&gt;-->
<!--&lt;!&ndash; redis单节点数据库连接配置 &ndash;&gt;-->
<!--<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">-->
<!--<property name="hostName" value="${redis.ip}" />-->
<!--<property name="port" value="${redis.port}" />-->
<!--<property name="password" value="${redis.pass}" />-->
<!--<property name="poolConfig" ref="jedisPoolConfig" />-->
<!--</bean> -->
<!--&lt;!&ndash; redisTemplate配置,redisTemplate是对Jedis的对redis操作的扩展,有更多的操作,封装使操作更便捷 &ndash;&gt;-->
<!--<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">-->
<!--<property name="connectionFactory" ref="jedisConnectionFactory" />-->
<!--</bean>-->
<!---->
</beans>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册