Redis测试
来源:互联网 发布:js检验只能输入数字 编辑:程序博客网 时间:2024/06/05 15:31
1.Test类
import org.junit.Test;import org.springframework.context.support.ClassPathXmlApplicationContext;import redis.clients.jedis.ShardedJedis;import redis.clients.jedis.ShardedJedisPool;public class RedisTest { static ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:spring-context.xml"); static ShardedJedisPool pool; static ShardedJedis jedis; static { context.start(); pool = (ShardedJedisPool) context.getBean("shardedJedisPool"); jedis = pool.getResource(); } /** * 添加数据 */ @Test public void testAdd() { jedis.set("1", "222"); System.out.println(jedis.get("1")); } /** * 追加数据 */ @Test public void testAppend() { jedis.append("1", "333"); System.out.println(jedis.get("1")); } /** * 修改数据 */ @Test public void testUpdate() { jedis.set("1", "444"); System.out.println(jedis.get("1")); } @Test public void testDel() { jedis.del("1"); System.out.println(jedis.get("1")); }}
spring-context配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd" default-autowire="byName" default-lazy-init="false"> <!-- 采用注释的方式配置bean --> <context:annotation-config /> <!-- proxy-target-class默认"false",更改为"ture"使用CGLib动态代理 --> <aop:aspectj-autoproxy proxy-target-class="true" /> <import resource="spring-redis.xml" /></beans>
spring-redis.xml配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Jedis链接池配置 --> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="testWhileIdle" value="true" /> <property name="minEvictableIdleTimeMillis" value="60000" /> <property name="timeBetweenEvictionRunsMillis" value="30000" /> <property name="numTestsPerEvictionRun" value="-1" /> <property name="maxTotal" value="8" /> <property name="maxIdle" value="8" /> <property name="minIdle" value="0" /> </bean> <bean id="shardedJedisPool" class="redis.clients.jedis.ShardedJedisPool"> <constructor-arg index="0" ref="jedisPoolConfig" /> <constructor-arg index="1"> <list> <bean class="redis.clients.jedis.JedisShardInfo"> <constructor-arg index="0" value="127.0.0.1" /> <constructor-arg index="1" value="6379" type="int" /> </bean> </list> </constructor-arg> </bean></beans>
0 0
- 测试redis
- Redis测试
- redis测试
- redis-benchmark 测试redis性能
- redis性能测试(redis-benchmark)
- Redis-benchmark测试Redis性能
- Redis压力测试
- redis 安装测试
- Redis插入性能测试
- Redis测试dos命令
- redis性能测试
- redis 入门测试
- Jedis读写Redis测试
- java测试redis
- redis读写性能测试
- redis安装与测试
- redis 测试工具benchmark
- redis java client测试
- The file “” couldn’t be opened because you don’t have permission to view it.
- 解决win7/win8.1 驱动调试KdPrint不能输出的问题
- 本文介绍Android中的5种数据存储方式。
- 字符集合-- 华为2016研发工程师编程题
- Android gif 动画
- Redis测试
- [OS复习]设备管理4
- java电子签章
- 14、canvas标签之事件
- mysql之触发器trigger ---谷营中西
- 注解
- 通过SE14重建数据库表
- HDU2476——String painter(区间dp)
- JZOJ 4709 Matrix【NOIP2016提高A组模拟8.17】