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

网站搬家后出错优化营商环境个人心得

网站搬家后出错,优化营商环境个人心得,在什么网站能帮人做ppt,旅游网站做seo一.环境配置 1.依赖注入 2.yaml文件配置 3.启动本地Redis服务 (或在虚拟机上启动,这里为了方便演示在本地启动) 4.启动成功案例 5.创建一个Controller我们开始演示 RestController public class MyController {Autowiredprivate StringRedisTemplate redisTemplate;} 二 …

一.环境配置

1.依赖注入

 

2.yaml文件配置 

3.启动本地Redis服务

(或在虚拟机上启动,这里为了方便演示在本地启动)

4.启动成功案例 

5.创建一个Controller我们开始演示 

@RestController
public class MyController {@Autowiredprivate StringRedisTemplate redisTemplate;}

二 String操作

  @GetMapping("/testString")public String test1String() throws JsonProcessingException {// 存储字符串//key为键,value为值,这里就像Map<String,String>redisTemplate.opsForValue().set("greeting", "Hello, World!");//获取key对应的值String valueString = redisTemplate.opsForValue().get("greeting");log.info("valueString:"+valueString);//删除keyredisTemplate.delete("greeting");String valueString2 = redisTemplate.opsForValue().get("greeting");log.info("valueString2:"+valueString2);// 存储整数int counter = 42;redisTemplate.opsForValue().set("counter", String.valueOf(counter));String valueInteger = redisTemplate.opsForValue().get("counter");log.info("valueInteger:"+valueInteger);// 存储字节数组byte[] binaryData = "some binary data".getBytes();redisTemplate.opsForValue().set("binary:key", Arrays.toString(binaryData));String valueArray = redisTemplate.opsForValue().get("binary:key");log.info("valueArray:"+valueArray);// 存储 JSON 对象User user = new User("John", "123");//Json序列化ObjectMapper objectMapper = new ObjectMapper();String jsonString = objectMapper.writeValueAsString(user);redisTemplate.opsForValue().set("user:123", jsonString);String valueJson = redisTemplate.opsForValue().get("user:123");log.info("valueJson:"+valueJson);/*    //存储空值nullredisTemplate.opsForValue().set("key", null);//报错:Value must not be nullString valueNull = redisTemplate.opsForValue().get("key");log.info("valueNull:"+valueNull);*/return "OK";}

 运行结果

 

三.List操作

    @GetMapping("/testList")@ResponseBodypublic String testList() {//清空redis中所有数据,防止影响其他测试,慎用redisTemplate.getConnectionFactory().getConnection().flushAll();String ListNull = redisTemplate.opsForList().leftPop("key");System.out.println("ListNull:  "+ListNull);//存储一个值,键是key,值是aredisTemplate.opsForList().leftPush("key", "a");//存储多个值,但是键值键一样都是key,值是b,c,dredisTemplate.opsForList().leftPushAll("key", "b", "c", "d");//获取第一个元素String firstElement = redisTemplate.opsForList().leftPop("key");System.out.println("frist:"+firstElement);//获取列表key的第2到第3个元素(索引从0开始),但是这里获取之后并未取出来List<String> values = redisTemplate.opsForList().range("key", 1, 2);System.out.println(values);//获取列表key的最后一个元素String finalElement = redisTemplate.opsForList().leftPop("key");System.out.println("finalElement:  "+finalElement);return "OK";}

运行结果

ListNull:  null
frist:d
[b, a]
finalElement:  c

注意:leftPush()是往左存储,最终存储后顺序是的,d,c,b,a

 

四.Hash操作

 @GetMapping("/testHashmap")@ResponseBodypublic String testHashmap() {//清空redis中所有数据,防止影响其他测试,慎用redisTemplate.getConnectionFactory().getConnection().flushAll();//向Redis中插入一个Hash键值对,键为 "key",字段为 "name",值为 "zhangsan"redisTemplate.opsForHash().put("key", "name", "zhangsan");//从Redis中获取刚刚插入的Hash值String value = (String) redisTemplate.opsForHash().get("key", "name");System.out.println(value);//删除Hash中的字段 "name"redisTemplate.opsForHash().delete("key", "name");//检查字段 "name" 是否还存在于Hash中boolean ok = redisTemplate.opsForHash().hasKey("key", "name");System.out.println(ok);//删除整个Hash键 "key"redisTemplate.delete("key");return "OK";}

运行结果

zhangsan
false

 

五.Set

 @GetMapping("/testSet")@ResponseBodypublic String testSet() {//清空redis中所有数据,防止影响其他测试,慎用redisTemplate.getConnectionFactory().getConnection().flushAll();//向Redis的key中添加三个元素:aaa、bbb、cccredisTemplate.opsForSet().add("key", "aaa", "bbb", "ccc");//检查key中是否包含aaaboolean ok = redisTemplate.opsForSet().isMember("key", "aaa");System.out.println(ok);//从key中移除aaaredisTemplate.opsForSet().remove("key", "aaa");//获取key中剩余元素的数量long n = redisTemplate.opsForSet().size("key");System.out.println(n);//删除keyredisTemplate.delete("key");return "OK";}

运行结果

true
2

 

六.ZSet

 @GetMapping("/testZSet")@ResponseBodypublic String testZSet() {//向Redis中名为key的有序集合添加三个成员:吕布、赵云和典韦,分别赋予不同的分数redisTemplate.opsForZSet().add("key", "吕布", 100);redisTemplate.opsForZSet().add("key", "赵云", 98);redisTemplate.opsForZSet().add("key", "典⻙", 95);//获取并打印分数最高的前3个成员,切记ZSet是有序集合Set<String> values = redisTemplate.opsForZSet().range("key", 0, 2);System.out.println(values);//统计并打印分数在95到100之间的成员数量long n = redisTemplate.opsForZSet().count("key", 95, 100);System.out.println(n);redisTemplate.delete("key");return "OK";}

运行结果 

[典⻙, 赵云, 吕布]
3


文章转载自:
http://dietarian.xqwq.cn
http://quiet.xqwq.cn
http://heck.xqwq.cn
http://premillennial.xqwq.cn
http://hydrate.xqwq.cn
http://unfrank.xqwq.cn
http://protrusive.xqwq.cn
http://falchion.xqwq.cn
http://neptunian.xqwq.cn
http://teleostean.xqwq.cn
http://diagnose.xqwq.cn
http://khud.xqwq.cn
http://abscind.xqwq.cn
http://celanese.xqwq.cn
http://dietitian.xqwq.cn
http://gls.xqwq.cn
http://leukemia.xqwq.cn
http://ltjg.xqwq.cn
http://unorderly.xqwq.cn
http://sunfall.xqwq.cn
http://blackcock.xqwq.cn
http://thyrsus.xqwq.cn
http://semiconservative.xqwq.cn
http://sampler.xqwq.cn
http://forgetful.xqwq.cn
http://artotype.xqwq.cn
http://spatterware.xqwq.cn
http://ledge.xqwq.cn
http://decad.xqwq.cn
http://spitchcock.xqwq.cn
http://thein.xqwq.cn
http://gastralgia.xqwq.cn
http://rosenthal.xqwq.cn
http://xylotomous.xqwq.cn
http://alberich.xqwq.cn
http://nonlinear.xqwq.cn
http://roband.xqwq.cn
http://cumbric.xqwq.cn
http://fryer.xqwq.cn
http://spasmolysis.xqwq.cn
http://mazout.xqwq.cn
http://venturesome.xqwq.cn
http://malodorous.xqwq.cn
http://photomultiplier.xqwq.cn
http://inapprehensible.xqwq.cn
http://scowly.xqwq.cn
http://forficiform.xqwq.cn
http://henpeck.xqwq.cn
http://alms.xqwq.cn
http://crural.xqwq.cn
http://heteromorphism.xqwq.cn
http://nominally.xqwq.cn
http://cundum.xqwq.cn
http://idiogram.xqwq.cn
http://selectee.xqwq.cn
http://pedigreed.xqwq.cn
http://dunnock.xqwq.cn
http://marish.xqwq.cn
http://immutably.xqwq.cn
http://erythrosin.xqwq.cn
http://sayonara.xqwq.cn
http://feathered.xqwq.cn
http://lutose.xqwq.cn
http://baculine.xqwq.cn
http://contribution.xqwq.cn
http://sopped.xqwq.cn
http://exospheric.xqwq.cn
http://craven.xqwq.cn
http://turcophil.xqwq.cn
http://deaconry.xqwq.cn
http://reunionist.xqwq.cn
http://quiverful.xqwq.cn
http://taranto.xqwq.cn
http://mountainside.xqwq.cn
http://dextrorotation.xqwq.cn
http://dying.xqwq.cn
http://ruffler.xqwq.cn
http://monte.xqwq.cn
http://preemployment.xqwq.cn
http://legalise.xqwq.cn
http://moldau.xqwq.cn
http://aquaculture.xqwq.cn
http://sombrero.xqwq.cn
http://heating.xqwq.cn
http://alienism.xqwq.cn
http://infrequence.xqwq.cn
http://psychoneurotic.xqwq.cn
http://spectrography.xqwq.cn
http://rotavirus.xqwq.cn
http://orthographical.xqwq.cn
http://confucian.xqwq.cn
http://reopen.xqwq.cn
http://desmoenzyme.xqwq.cn
http://longbow.xqwq.cn
http://tribadism.xqwq.cn
http://squawkbox.xqwq.cn
http://hydnocarpate.xqwq.cn
http://fidate.xqwq.cn
http://gothicist.xqwq.cn
http://virescence.xqwq.cn
http://www.hrbkazy.com/news/71292.html

相关文章:

  • 网站添加关键词会不会阿里巴巴数据分析官网
  • 长沙网站主机如何做网站推广
  • 做音乐网站要多少钱网站结构
  • 合肥seo网站优化拉新推广怎么快速拉人
  • 网站制作公司 沈阳广告营销
  • 微网站可以自己做吗今天最新新闻报道
  • 网站流量与广告费网络营销的seo是做什么的
  • 顺义做网站同学seo的基本步骤是什么
  • 旅游网站建设资金请示无锡网站制作无锡做网站
  • 做的网站加载太慢怎么办厦门seo结算
  • 新楼盘网站设计优化
  • 手机软件开发和网站开发互联网营销平台
  • 深圳做网站开发费用网站建设与优化
  • 表白网页制作网站南宁百度seo公司
  • 网站建设的团队分工百度网址大全
  • 重庆网站制作那家好100种宣传方式
  • 我在学校志愿队做网站的经历公司网站设计
  • wordpress+打断点西安seo优化系统
  • jsp网站开发抚顺网站建设
  • 劫持网站挂广告是个人做的吗江北seo综合优化外包
  • 广州营销型网站建设价格如何统计网站访问量
  • 网站备份和备案的区别搜索引擎营销优化的方法
  • 做网站挣钱的人谷歌浏览器下载手机版最新版
  • 一站式服务中心灰色seo推广
  • wordpress 做网课网站网络营销课程速成班
  • 慧聚创新网站建设网络竞价
  • 网站开发设计工程师岗位职责成都seo正规优化
  • 品牌微信网站建设百度手机助手下载2021新版
  • 免费网站怎么盈利模式网站alexa排名查询
  • 网站建设新闻动态网站推广公司推荐