找产品做代理都有哪个网站,建网站需求,矿泉水瓶50种手工制作,上饶网站建设多少钱jedis就像jdbc一样#xff0c;用于两个端直接的连接。
1.创建Spring项目
这里不过多赘述...
2.导入连接工具jedis
在pom文件中导入jedis的依赖。 dependencygroupIdredis.clients/groupIdartifactIdjedis/artifactIdversion用于两个端直接的连接。
1.创建Spring项目
这里不过多赘述...
2.导入连接工具jedis
在pom文件中导入jedis的依赖。 dependencygroupIdredis.clients/groupIdartifactIdjedis/artifactIdversion4.3.1/version//版本号根据需要选择/dependency
3.创建jedis对象
//redis所在主机的IP地址和监听的端口
Jedis jedis new Jedis(IP地址, 端口号);
//指定访问服务器的密码
jedis.auth(132132qa..);
4.测试是否连通
jedis.ping()
System.out.println(jedis.ping());//若输出为PONG表示连通
之后就可以通过jedis进行操作啦——
SetString set jedis.keys(*);
jedis.set(name, qyyb);
MapString, String map new HashMap();
jedis.hset(tengjie,map);
....................
Jedis和Lettuce区别
Jedis客户端连接时都需要创建实例造成很大开销。线程之间也不安全一个线程修改会对别的线程影响。
Lettuce底层使用Netty保证只创建一个Lettuce连接所有线程共享故也不会存在数据修改对别的线程影响。
RedisTemplate使用
pom配置
dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId
/dependency
dependencygroupIdorg.apache.commons/groupIdartifactIdcommons-pool2/artifactId
/dependency
dependencygroupIdio.springfox/groupIdartifactIdspringfox-swagger2/artifactIdversion3.0.0/version
/dependency
dependencygroupIdio.springfox/groupIdartifactIdspringfox-swagger-ui/artifactIdversion3.0.0/version
/dependency
properties文件配置 SwaggerConfig配置 注入bean并操作 显示中文启动redis加上--raw
感谢观看——