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

某企业网站建设论文如何刷seo关键词排名

某企业网站建设论文,如何刷seo关键词排名,网页设计秀丽南宁,百度官方网页版应用场景 存放Token、存放用户信息或字典等需要频繁访问数据库获取但不希望频繁访问增加数据库压力且变化不频繁的数据。 集成步骤 1. 新建 Maven 项目并引入 redis 依赖【部分框架有可能已经集成&#xff0c;会导致依赖文件有差异】 <dependency><groupId>org…

应用场景

存放Token、存放用户信息或字典等需要频繁访问数据库获取但不希望频繁访问增加数据库压力且变化不频繁的数据。

集成步骤

1. 新建 Maven 项目并引入 redis 依赖【部分框架有可能已经集成,会导致依赖文件有差异】

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

2. 配置 application.yml文件

#数据源配置
spring:redis:##redis 单机环境配置# Redis服务器地址host: 127.0.0.1# Redis服务器连接端口port: 6379password:# Redis数据库索引(默认为0)database: 0ssl: falsedatasource:url: jdbc:mysql://*.***.**.**:3516/smart_order?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=trueusername: rootpassword: ******

3. 编写缓存服务和Controller

spring-boot 自动配置了 RedisConnectionFactory, StringRedisTemplate 和 RedisTemplate Bean。
默认,连接的 redis 服务端为 localhost:6379

CacheService 接口

/*** 缓存服务* @param <K>  缓存的 key* @param <V>  缓存的内容*/
public interface CacheService<K,V> {Boolean cache(K key, V value);Boolean remove(K key);V get(K key);}

RedisCacheService

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;/*** 基于 Redis 实现的的缓存服务*/
@Service("redisCacheService")
public class RedisCacheService implements CacheService<String, Object>{//  spring-boot 自动配置了 RedisConnectionFactory, StringRedisTemplate 和 RedisTemplate Bean。@Autowiredprivate RedisConnectionFactory connectionFactory;@Autowiredprivate StringRedisTemplate template;@Autowired@Qualifier("redisTemplate")private RedisTemplate redisTemplate;@Overridepublic Boolean cache(String key, Object value) {template.opsForValue().set(key,String.valueOf(value));return Boolean.TRUE;}@Overridepublic Boolean remove(String key) {return template.delete(key);}@Overridepublic Object get(String key) {return template.opsForValue().get(key);}
}

CacheController

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;/*** CacheController 用于提供 接口进行缓存操作*/
@RestController
@RequestMapping("/cache")
public class CacheController {@Autowired@Qualifier("redisCacheService")private CacheService cacheService;/*** 缓存* @param key* @param value* @return*/@GetMapping("/save")public Boolean cache(@RequestParam("key") String key, @RequestParam("value")String value){return cacheService.cache(key,value);}/*** 查询* @param key 缓存key* @return*/@GetMapping("/get")public Object get(@RequestParam("key") String key){return cacheService.get(key);}/*** 删除缓存* @param key 缓存key* @return*/@GetMapping("/remove")public Boolean remove(@RequestParam("key") String key){return cacheService.remove(key);}
}

4. 下载redis并打开

  • Redis3.0下载地址https://redis.io/download/
  • 解压后,打开其中的redis-server.exe即可。
    在这里插入图片描述

5. 启动项目并测试

在SpirngBoot测试类中,先用@Autowired引入RedisCache。通过调用该对象的方法来操作redis数据库。

@Autowired
private RedisCache redisCache;@Test
void TextRedisXX() {redisCache.setCacheObject("hhh", "123");String str = redisCache.getCacheObject("hhh");System.out.println(str);
}

亦或是容器初始化时获取

StringRedisTemplate redisTemplate = SpringUtil.getBean(StringRedisTemplate.class);

结果如下图:
在这里插入图片描述
除了在IDEA中通过调用 redisCache.getCacheObject(“hhh”);方法来获取之外,还可以打开解压文件中的redis-cli.exe,输入 get hhh 来获 取值。
在这里插入图片描述

http://www.shuangfujiaoyu.com/news/43120.html

相关文章:

  • 深圳做外贸网站seo怎么优化关键词排名
  • 组培实验室建设网站流量大的推广平台有哪些
  • mvc5 网站开发之學 pdf百度网盘登录入口官网
  • mac可以做网站开发吗seo建站教学
  • 网站更换域名多少钱优化关键词排名的工具
  • 怎么生成域名做网站seo搜索引擎优化
  • 商城网站开发定制媒体公关
  • 网站建设的编程技术上海网站排名优化公司
  • 广州网站设计找谁必应搜索引擎
  • 新手做网站什么内容比较好百度学术免费查重入口
  • 公司要求做网站常用网站推广方法及资源
  • 用织梦做模板网站湖南长沙最新疫情
  • 房地产建筑公司网站合肥网络公司seo建站
  • 网站备案被注销品牌推广包括哪些内容
  • 深圳购物商城网站建设清远疫情防控措施
  • 汕尾住房和建设局网站首页东莞搜索引擎推广
  • 昆山网站建设培训学校免费站长工具
  • 海口双语网站建设上海哪家seo好
  • 青岛有没有做网站的小江seo
  • 贵阳网站建设设计成人技术培训学校
  • 上海建筑工程招投标网网站推广及seo方案
  • 做视频网站用什么语言seo课培训
  • 音乐网站设计规划书网络营销seo培训
  • 网站做批发文具微博推广怎么做
  • 淘宝网站建设类目需要什么资质搜索引擎优化关键字
  • 网站建设的预算seo是什么
  • 如何找外贸网站建设公司百度识图入口
  • 电影网站html模板google搜索引擎入口
  • 用eclipse做网站 seo won
  • 传播型网站建设优势有哪些职业培训机构资质