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

江西赣州网站网站优化seo技术

江西赣州网站,网站优化seo技术,广州工程项目,seo搜索引擎优化论文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://www.dtcms.com/a/443921.html

相关文章:

  • 做网站工资多少钱wordpress 用户 字段
  • 怎么做自己的网站后台教程门户网站界面设计
  • 萧山网站优化响应式网站模板 开源
  • 山东钢结构建设局网站上传到服务器的网站打开是空白
  • 外贸 企业网站 建设网站设计论文总结与展望
  • 建立网站需要多少钱就蓷y湖南岚鸿推荐宁波中小企业网站制作
  • 啤酒网站建设注册网站建设公司
  • 课程网站建设的目的意义乐陵关键词seo
  • 外卖项目技术亮点总结笔记
  • 做教育网站还挣钱吗dw做的网站怎么上传
  • 一诺网站建设湖南 微网站开发与设计比赛
  • 济南网站建设流程网站asp.net安装
  • 手机网站活动策划方案珠海品牌型网站建设
  • 阿里巴巴网站怎么做全屏大图公司建设内容是什么
  • 网站建设维护属于什么专业网站开发常用的谷歌插件
  • html页面能做成网站吗类似情侣空间的网站开发
  • 做招聘网站需要什么资质苏州行业网络推广排名稳定
  • 自适应滤波器减轻光照对卷心菜识别准确性影响
  • 宁波外贸网站制作公司必应网站收录在哪
  • 元宇宙与文化传承:数字技术保护文化遗产
  • OpenSearch/Ingest Pipeline + k-NN 在 ABP 的“双索引”落地
  • 手机网站 手机app微信会员卡管理系统
  • 做网站详细步骤非法网站开发
  • 北京建设执业网站网站开发电脑内存要多少钱
  • 怎么做晒鱼的网站电话手表网站
  • 深圳北网站建设王也天与葛优
  • 太原网站建设方案做简历用的网站
  • 重庆的做网站公司wap网站浏览器
  • 历史看过的网站网站建设工作
  • 如何学会建网站wordpress电源模板