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

会小二也是做会议网站的推广方案流程

会小二也是做会议网站的,推广方案流程,wordpress网站怎么进入后台,廊坊网站建设选择青橙网络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/wzjs/110354.html

相关文章:

  • 天津自制网站建设产业网站服务费一年多少钱
  • 做网站的公司 苏迪怎么弄一个自己的网站
  • 什么是纯动态网站网络营销的四个步骤
  • wordpress+苏醒主题外贸网站seo教程
  • 河北建设厅网站打不开是什么原因企业网络推广方案
  • 给彩票网站做排名违法吗微信营销推广的方式有哪些
  • 上海网站建设制作微信韩国搜索引擎排名
  • 建设校园标准信息服务网站论文东莞商城网站建设
  • 网站后缀ga搜索词
  • 松江网站建设培训费用信息推广平台有哪些
  • 嵊州网站建设全网整合营销
  • 呼市做网站公司深圳整站全网推广
  • 北京发展和城乡建设委员会网站最常用的搜索引擎有哪些
  • 淄博个人承接网站制作下载百度app
  • 郑州做网站云极网站关键词优化报价
  • 张店政府网站建设哪家好河南seo技术教程
  • 徐州网站外包网站检测工具
  • 供应网站建设深圳网站建设的公司
  • 日本网站香港服务器seo超级外链工具
  • 选择响应式网站建设武汉网络推广有限公司
  • html中文网站作业2021国内最好用免费建站系统
  • 海外产品网站建设黑帽seo什么意思
  • 国外做饮料视频网站百度关键词规划师工具
  • 湛江市政工程建设公司网站西安核心关键词排名
  • 网站开发建设推荐用书淘宝网官方网站
  • 网站 icp备案想学管理方面的培训班
  • 免费网站建设资讯软文营销的作用有哪些
  • 看想看的做想做的电影网站好软文推广是什么意思?
  • 做网站所需要的项武汉seo百度
  • 上海专业做网站公网站建设公司官网