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

邯郸做网站的公司建设公司是什么意思

邯郸做网站的公司,建设公司是什么意思,朋友圈海报用什么网站做的,健康养老网站建设Redis简介: rRedis服务开启与停止: 服务开启: 在Redis配置文件中输入cmd进入命令行输入redis-server redis-cli.exe -h -p:连接到redis服务 设置密码:在redis.windows.conf中找到requirepass 密码 服务停止: 在服务开启的界面按ctrlc Redis数据类…

Redis简介:

rRedis服务开启与停止:

服务开启:

在Redis配置文件中输入cmd进入命令行输入redis-server

redis-cli.exe -h -p:连接到redis服务

设置密码:在redis.windows.conf中找到requirepass 密码

服务停止:

在服务开启的界面按ctrl+c

Redis数据类型:

各种数据类型的特点:

Redis常用命令:

在java中操作Reids:

Redis的java客户端:

1.导入Spring Data Redis的maven坐标

        <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>

2.配置Redis数据源

sky:datasource:driver-class-name: com.mysql.cj.jdbc.Driverhost: localhostport: 3306database: sky_take_outusername: rootpassword: CHC52099maintainTimeStats: trueredis:host: localhostport: 6379database: 10

3.编写配置类,创建RedisTemplate对象

package com.sky.config;import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;@Configuration
@Slf4j
public class RedisConfiguration {@Beanpublic RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {log.info("开始创建redis模板对象...");RedisTemplate redisTemplate = new RedisTemplate();//设置redis的连接工厂对象redisTemplate.setConnectionFactory(redisConnectionFactory);//设置redis的key序列化器redisTemplate.setKeySerializer(new StringRedisSerializer());return redisTemplate;}
}

4.通过RedisTemplate对象操作Redis

package com.sky.test;import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.*;import java.util.concurrent.TimeUnit;@SpringBootTest
public class SpringDataRedis {@Autowiredprivate RedisTemplate redisTemplate;@Testpublic void testRedisTemplate() {System.out.println(redisTemplate);ValueOperations valueOperations = redisTemplate.opsForValue();HashOperations hashOperations = redisTemplate.opsForHash();ListOperations listOperations = redisTemplate.opsForList();SetOperations setOperations = redisTemplate.opsForSet();ZSetOperations zSetOperations = redisTemplate.opsForZSet();}/*** 操作字符串类型的数据*/@Testpublic void testString() {redisTemplate.opsForValue().set("hello", "world");System.out.println(redisTemplate.opsForValue().get("hello"));redisTemplate.opsForValue().setIfAbsent("hello", "sky");redisTemplate.opsForValue().setIfPresent("hello", "sky",3, TimeUnit.MINUTES);}@Testpublic void testHash(){redisTemplate.opsForHash().put("sky","name","sky");redisTemplate.opsForHash().put("sky","age",18);System.out.println(redisTemplate.opsForHash().get("sky","name"));System.out.println(redisTemplate.opsForHash().get("sky","age"));}
}

设置营业状态:

需求说明:

controller层:

package com.sky.controller.admin;import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口")
@Slf4j
public class ShopController {@Autowiredprivate RedisTemplate redisTemplate;/*** 设置店铺营业状态** @param status* @return*/@RequestMapping("/{status}")@ApiOperation("设置店铺状态")public Result setStatus(@PathVariable Integer status) {log.info("设置店铺状态为:{}", status == 1 ? "营业中" : "打烊了");redisTemplate.opsForValue().set("SHOP_STATUS", status);return Result.success();}@GetMapping("/status")@ApiOperation("获取店铺营业状态")public Result<Integer> getStatus() {Integer status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");log.info("获取店铺营业状态为:{}", status == 1 ? "营业中" : "打烊了");return Result.success(status);}}

然后拿接口文档测试没有问题


文章转载自:

http://T6PIvgF4.kpzbf.cn
http://O1vF7Vcj.kpzbf.cn
http://GE6fmxDY.kpzbf.cn
http://MbzsLKX7.kpzbf.cn
http://WIyAGS2a.kpzbf.cn
http://4eA72uf6.kpzbf.cn
http://6igzvDe3.kpzbf.cn
http://DE262hWl.kpzbf.cn
http://ZljADwd0.kpzbf.cn
http://kF3ZXA4Z.kpzbf.cn
http://dXYKSY1R.kpzbf.cn
http://refMCgJZ.kpzbf.cn
http://fv9bTAgM.kpzbf.cn
http://IQLQ1Yk6.kpzbf.cn
http://5TQX3Umr.kpzbf.cn
http://3g9UZ0vG.kpzbf.cn
http://5yZv23Yy.kpzbf.cn
http://o5OCtVkF.kpzbf.cn
http://pde3YjpA.kpzbf.cn
http://yxpkJkvj.kpzbf.cn
http://St27qVBE.kpzbf.cn
http://dNBSmkZF.kpzbf.cn
http://cToxVsTd.kpzbf.cn
http://w3QcfZtr.kpzbf.cn
http://3SFW9u9u.kpzbf.cn
http://AERdp1FC.kpzbf.cn
http://39CYIhlB.kpzbf.cn
http://ZvulpOoB.kpzbf.cn
http://uqIQa9Wd.kpzbf.cn
http://elIqxLJo.kpzbf.cn
http://www.dtcms.com/wzjs/687898.html

相关文章:

  • iis网站asp.net部署wordpress菜单页面跳转
  • 石家庄免费网站建设腾讯的wordpress怎么样
  • 广西省建设注册管理网站公司注册域名需要哪些条件
  • 网上商城网站开发公司如何做赚钱的网站
  • 电子商务网站开发的任务书我局 负责 建设 网站
  • 长沙网站建设260ewordpress在线
  • 网站前端设计培训黄石网站网站建设
  • dw做网站首页长宽设置多少腾讯云主机
  • 好看的ui网站页面设计有找专业做淘宝网站的美工
  • 电商网站建设的现实意义是什么主题公园网站建设
  • 百度收录检测如何优化网站标题
  • 网站建设中标公告如何使用云服务建设网站
  • 大连科技学院官方网站的建设与放店铺logo在线免费制作
  • 福州网站制作有限公司网站开发报价单
  • 做网站的网站赚钱吗外发加工会计分录
  • 德兴市网站建设服务公司成都seo培训班
  • 毕业设计可以做自己的网站吗住房和城乡建设岗位证书
  • 长垣做网站两学一做教育纪实评价系统网站
  • 室内装饰设计师证书seo推广营销网站
  • 安全认证的机票网站成就怎么做装修设计案例网站
  • 做asp网站教程wordpress 目录样式
  • 搭建网站要不要给域名对方wordpress 手机首页设置
  • 建设专业网站电话咨询珠海网站建设网
  • 酒店宾馆客栈旅馆古典网站源码 asp源码带后台乐清seo公司
  • 网站做外链平台有哪些免费
  • 哪个网站课件做的比较好做装修的网站有哪些内容
  • 想自己做网站该学些什么音乐资源网站开发
  • 网站没有内容 能做优化吗外贸网站推广 sit
  • 66郑州网站建设推广文案范文100字
  • 长治市住房保障和城乡建设管理局网站电子商务网站建设题6