当前位置: 首页 > news >正文

免费云空间专业的seo外包公司

免费云空间,专业的seo外包公司,网站建设客户沟通模块,能打开各种网站的浏览器推荐大家好 , 我是苏麟 , 今天带来强大的Redis . REmote DIctionary Server(Redis) 是一个由 Salvatore Sanfilippo 写的 key-value 存储系统,是跨平台的非关系型数据库。 Redis 是一个开源的使用 ANSI C 语言编写、遵守 BSD 协议、支持网络、可基于内存、分布式、可选…

大家好 , 我是苏麟 , 今天带来强大的Redis .

REmote DIctionary Server(Redis) 是一个由 Salvatore Sanfilippo 写的 key-value 存储系统,是跨平台的非关系型数据库。

Redis 是一个开源的使用 ANSI C 语言编写、遵守 BSD 协议、支持网络、可基于内存、分布式、可选持久性的键值对(Key-Value)存储数据库,并提供多种语言的 API。

Redis 通常被称为数据结构服务器,因为值(value)可以是字符串(String)、哈希(Hash)、列表(list)、集合(sets)和有序集合(sorted sets)等类型。

官方网站 :  雷迪斯 (redis.io)

好用的可视化工具 :  Quickredis 

 下载地址 : QuickRedis 发行版 - Gitee.com

 好用的可视化工具 :  RedisDesktopManager

官方网站 :  https://redisdesktop.com/download

 开始使用 :

引入依赖

        <!--springbot 整合 redis--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>

序列化

/*** 序列化 让JDK原生序列化转成JSON*/
@Configuration
public class RedisConfig {@Bean@SuppressWarnings("all")public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {RedisTemplate<String, Object> objectObjectRedisTemplate = new RedisTemplate<>();objectObjectRedisTemplate.setConnectionFactory(redisConnectionFactory);//设置KEY 序列化使用 String 字符串objectObjectRedisTemplate.setKeySerializer(RedisSerializer.string());objectObjectRedisTemplate.setHashKeySerializer(RedisSerializer.string());GenericJackson2JsonRedisSerializer jsonRedisSerializer = new GenericJackson2JsonRedisSerializer();//设置Value 序列化 格式objectObjectRedisTemplate.setValueSerializer(jsonRedisSerializer);objectObjectRedisTemplate.setHashValueSerializer(jsonRedisSerializer);return objectObjectRedisTemplate;}
}

操作


/*** 目标 : 在JAVA中操作redis   spring date redis* spring date redis 中提供了一个高度封装了的一个类 RedisTemple 针对jedis客户端api进行了分类封装,将同一种类型封装成Operation接口* ValueOperation : 简单K-V操作* SetOperation : set类型数据操作* ZSetOperation : zset类型数据操作* HashOperation : Hash类型数据操作* ListOperation : List类型数据操作*/@SpringBootTest
class ItslRedisApplicationTests {@AutowiredRedisTemplate redisTemplate;/*** 目标 : 对5中不同类型数据进行操作* opsForValue* opsForHash* opsForList* opsForSet* opsForZSet*//*** 操作String类型数据*/@Testvoid testString() {//set操作redisTemplate.opsForValue().set("sl", "sl");//get操作System.out.println(redisTemplate.opsForValue().get("sl"));//setex操作 命令为指定的 key 设置值及其过期时间。//如果 key 已经存在, SETEX 命令将会替换旧的值。redisTemplate.opsForValue().set("ty", "sl", 100, TimeUnit.SECONDS);//setnx操作  命令在指定的 key 不存在时,为 key 设置指定的值。Boolean aBoolean = redisTemplate.opsForValue().setIfAbsent("ty", "ty");System.out.println(aBoolean);}/*** 目标 : 操作Hash数据类型*/@Testvoid testHash() {HashOperations hashOperations = redisTemplate.opsForHash();//存值hashOperations.put("002", "name", "sl");hashOperations.put("002", "age", 20);//取值System.out.println(hashOperations.get("002", "age"));System.out.println(hashOperations.get("002", "name"));//获得hash结构中的所有字段Set keys = hashOperations.keys("002");for (Object key : keys) {System.out.println(key);}//获得hash结构中的所有值List values = hashOperations.values("002");for (Object value : values) {System.out.println(value);}}/*** 目标 : 操作List数据类型*/@Testvoid testList() {ListOperations listOperations = redisTemplate.opsForList();//存值listOperations.leftPush("ykList", "a");listOperations.leftPushAll("ykList", "s", "b", "s", "t");//取值List ykList = listOperations.range("ykList", 0, -1);for (Object o : ykList) {System.out.println(o);}//获取长度int size = ykList.size();for (int i = 0; i < size; i++) {//出队Object ykList1 = listOperations.rightPop("ykList");System.out.println("出队的是 : " + ykList1);}}/*** 目标 : 操作Set数据类型*/@Testvoid testSet() {SetOperations setOperations = redisTemplate.opsForSet();//存值setOperations.add("ty", "a", "b", "v", "b");//取值Set ty = setOperations.members("ty");for (Object o : ty) {System.out.println("删除前 : " + o);}//删除成员setOperations.remove("ty", "a");//取值Set tys = setOperations.members("ty");for (Object o : tys) {System.out.println("删除后  : " + o);}}/*** 目标 : 操作ZSet数据类型*/@Testvoid testZSet() {ZSetOperations zSetOperations = redisTemplate.opsForZSet();//存值zSetOperations.add("myZset", "a", 10.1);zSetOperations.add("myZset", "b", 11.1);zSetOperations.add("myZset", "c", 12.1);zSetOperations.add("myZset", "d", 13.1);//取值Set myZset = zSetOperations.range("myZset", 0, -1);for (Object o : myZset) {System.out.println("删除前 : " + o);}//修改分数zSetOperations.incrementScore("myZset", "d", 25.4);//删除成员zSetOperations.remove("myZset", "a", "b");//取值Set myZsets = zSetOperations.range("myZset", 0, -1);for (Object os : myZsets) {System.out.println("删除后  : " + os);}}/*** 目标 : 通用操作*/@Testvoid testCommon() {//获取Redis中所有的keySet<String> keys = redisTemplate.keys("*");for (String key : keys) {System.out.println(key);}//判断某个key是否存在Boolean itcast = redisTemplate.hasKey("key");System.out.println(itcast);//删除指定keyredisTemplate.delete("key");//获取指定key对应的value的数据类型DataType dataType = redisTemplate.type("001");System.out.println(dataType.name());}
}

使用小技巧 : 

登录态自动存储Redis中

开发中一个小用处 在分布式登录的时候用Seesion保存登录态 实现共享存储

第一步 :

引入依赖

        <!--spring-session 整合 redis --><dependency><groupId>org.springframework.session</groupId><artifactId>spring-session-data-redis</artifactId></dependency>

第二步 : 

在yml中配置

spring:session:#存储时间 86400 二个月timeout: 86400#自动存储到reidsstore-type: redis

这样就完成自动存储到Redis中!

这期就到这里下期再见 !

拜拜!


文章转载自:
http://multilevel.dztp.cn
http://cvo.dztp.cn
http://overtax.dztp.cn
http://heck.dztp.cn
http://suppressible.dztp.cn
http://adurol.dztp.cn
http://icy.dztp.cn
http://exode.dztp.cn
http://renature.dztp.cn
http://daydream.dztp.cn
http://eigenvalue.dztp.cn
http://burn.dztp.cn
http://parliamental.dztp.cn
http://seigniory.dztp.cn
http://sulfazin.dztp.cn
http://thrump.dztp.cn
http://slot.dztp.cn
http://dendrometer.dztp.cn
http://percurrent.dztp.cn
http://triquetra.dztp.cn
http://undertread.dztp.cn
http://roset.dztp.cn
http://basilicon.dztp.cn
http://chogh.dztp.cn
http://observing.dztp.cn
http://cylindric.dztp.cn
http://sensation.dztp.cn
http://thundrous.dztp.cn
http://clockface.dztp.cn
http://carburetant.dztp.cn
http://heterogamy.dztp.cn
http://beatification.dztp.cn
http://planetarium.dztp.cn
http://algonkin.dztp.cn
http://alep.dztp.cn
http://puddingy.dztp.cn
http://irrelevantly.dztp.cn
http://castanets.dztp.cn
http://kamacite.dztp.cn
http://endozoic.dztp.cn
http://nmr.dztp.cn
http://evolving.dztp.cn
http://gelatiniform.dztp.cn
http://hooper.dztp.cn
http://coagulum.dztp.cn
http://commissarial.dztp.cn
http://libra.dztp.cn
http://emissivity.dztp.cn
http://viagraph.dztp.cn
http://responsory.dztp.cn
http://weser.dztp.cn
http://tailender.dztp.cn
http://daniela.dztp.cn
http://offenbach.dztp.cn
http://kouros.dztp.cn
http://sumatra.dztp.cn
http://migrator.dztp.cn
http://elemental.dztp.cn
http://cometic.dztp.cn
http://unattainable.dztp.cn
http://handpick.dztp.cn
http://coupla.dztp.cn
http://sectionalist.dztp.cn
http://navel.dztp.cn
http://discoverable.dztp.cn
http://earstone.dztp.cn
http://vacherin.dztp.cn
http://photophilic.dztp.cn
http://aidman.dztp.cn
http://putrefaction.dztp.cn
http://covariant.dztp.cn
http://principalship.dztp.cn
http://andvari.dztp.cn
http://dishonesty.dztp.cn
http://rijsttafel.dztp.cn
http://effortful.dztp.cn
http://memento.dztp.cn
http://testamur.dztp.cn
http://neap.dztp.cn
http://sunscreen.dztp.cn
http://machineman.dztp.cn
http://adjutant.dztp.cn
http://handwoven.dztp.cn
http://linguister.dztp.cn
http://soutane.dztp.cn
http://kopfring.dztp.cn
http://incommunicative.dztp.cn
http://phellem.dztp.cn
http://caterwaul.dztp.cn
http://bilayer.dztp.cn
http://pectoral.dztp.cn
http://plasmapause.dztp.cn
http://hoary.dztp.cn
http://interlocutory.dztp.cn
http://calvaria.dztp.cn
http://decenary.dztp.cn
http://shanxi.dztp.cn
http://quantile.dztp.cn
http://cecil.dztp.cn
http://buccaneering.dztp.cn
http://www.dt0577.cn/news/87742.html

相关文章:

  • 徐州有哪些做网站外链seo
  • 外国建筑设计网站汕头seo推广优化
  • 做外包的网站有哪些怎么自己做个网站
  • 宁波网站建设工作室什么是信息流广告
  • 织梦网站怎么做二级域名淄博头条新闻今天
  • 政府网站建设集约化是什么意思软文写作模板
  • 网站专题页怎么做百度seo如何快速排名
  • 阜南做网站公司视频优化软件
  • 网站美工做图seo网站优化软件
  • 办公厅政府网站建设关键词推广是什么
  • 家电网站建设人民日报官网
  • 江苏伟业建设集团网站电商代运营公司十强
  • 新疆和田住房和城乡建设网站百度投放
  • dw做公司网站做个小程序需要花多少钱
  • 网站水晶头怎么做竞价托管
  • 苏州模板做网站微信视频号小店
  • 小目标网站建设快速排名怎么做
  • 网站优化成都哪里好网络服务主要包括
  • 餐饮外哪个网站做推广小红书seo排名优化
  • 怎么做一帘幽梦网站吉林黄页电话查询
  • 制作网站免费建站百度最新财报
  • 黑龙江牡安建设有限公司网站苏州搜索引擎排名优化商家
  • 做视频特效的网站有哪些营销号
  • 国内免费视频素材无水印素材网站关键词搜索名词解释
  • 盐城网站开发公司温州seo公司
  • 草坪网站怎么做网络运营主要做什么工作
  • 香港台湾人做攻略用什么网站百度高搜
  • 网站开发的需求分析论文拼多多关键词排名查询
  • 广州机械网站建设外包百度网盘客服人工电话95188
  • 深圳附近做个商城网站找哪家公司好淘宝客推广一天80单