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

建设银行官方投诉网站seo是什么意思 seo是什么职位

建设银行官方投诉网站,seo是什么意思 seo是什么职位,wordpress编辑器插件哪个好,商标转让费用多少1. 项目源代码 为了方便演示,以及大家上手实验,我搭建了一个简单的注册登录的后台,在不加 Redis 的情况下的源代码如下 通过网盘分享的文件:study-无redis.zip 链接: https://pan.baidu.com/s/1etc29in_6q8CDOFm-Gb7Nw?pwdyuer…

1. 项目源代码

为了方便演示,以及大家上手实验,我搭建了一个简单的注册登录的后台,在不加 Redis 的情况下的源代码如下

通过网盘分享的文件:study-无redis.zip
链接: https://pan.baidu.com/s/1etc29in_6q8CDOFm-Gb7Nw?pwd=yuer 提取码: yuer

2. 数据库结构

数据库结构如下所示:

/*Navicat Premium Data TransferSource Server         : localhost_3306Source Server Type    : MySQLSource Server Version : 80016Source Host           : localhost:3306Source Schema         : redisTarget Server Type    : MySQLTarget Server Version : 80016File Encoding         : 65001Date: 07/04/2025 10:55:27
*/SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;-- ----------------------------
-- Table structure for usr
-- ----------------------------
DROP TABLE IF EXISTS `usr`;
CREATE TABLE `usr`  (`uid` int(11) NOT NULL,`username` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,PRIMARY KEY (`uid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of usr
-- ----------------------------
INSERT INTO `usr` VALUES (1, 'yuer', 'yuerpass');
INSERT INTO `usr` VALUES (686, '123', '456');SET FOREIGN_KEY_CHECKS = 1;

3. Redis集成

接下来我们添加 Redis 支持:

3.1 添加 Redis 依赖

		<!-- Redis依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><!-- 添加Jackson序列化依赖 --><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId></dependency>

3.2 配置 Redis

在 config 包下新建一个 RedisConfig 类:

package com.yuer.config;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.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;@Configuration
public class RedisConfig {@Beanpublic RedisTemplateredisTemplate(RedisConnectionFactory connectionFactory) {RedisTemplateredisTemplate = new RedisTemplate<>();redisTemplate.setConnectionFactory(connectionFactory);// 使用StringRedisSerializer来序列化和反序列化redis的key值redisTemplate.setKeySerializer(new StringRedisSerializer());// 使用GenericJackson2JsonRedisSerializer来序列化和反序列化redis的value值GenericJackson2JsonRedisSerializer jsonRedisSerializer = new GenericJackson2JsonRedisSerializer();redisTemplate.setValueSerializer(jsonRedisSerializer);// Hash的key也采用StringRedisSerializer的序列化方式redisTemplate.setHashKeySerializer(new StringRedisSerializer());// Hash的value也采用GenericJackson2JsonRedisSerializer的序列化方式redisTemplate.setHashValueSerializer(jsonRedisSerializer);redisTemplate.afterPropertiesSet();return redisTemplate;}
}

3.3 配置 application.properties

spring.redis.host=localhost
spring.redis.port=6379
# spring.redis.password=
spring.redis.database=0
spring.redis.timeout=3000

3.4 修改 UserService 实现类

修改 userservice.impl 中的登录方法:

@Override
public User login(String username, String password) {// 根据用户名查询用户User user = userMapper.selectByUsername(username);// 从缓存中读取登录的数据User cachedUser = (User) redisTemplate.opsForValue().get("user:" + user.getUid().toString());if(cachedUser != null) {System.out.print("缓存命中!登录成功!");} else {System.out.print("未寻找到缓存,准备使用mysql查询");}// 如果用户存在且密码匹配,则登录成功,通过数据库,并且缓存redisif (user != null && password.equals(user.getPassword())) {redisTemplate.opsForValue().set("user:" + user.getUid().toString(), user);return user;}// 登录失败return null;
}

4. 登录流程演示(测试Redis)

当用户首次登录时,需要从 MySQL 查询用户信息,之后可以缓存登录的数据。

4.1 第一次登录

第一次登录需要查询 MySQL:

4.2 第二次登录

第二次登录时,已缓存登录数据:

5. 清除 Redis 缓存

如果需要清除 Redis 缓存数据,可以使用以下命令:

# 连接到 Redis
redis-cli# 清除当前数据库缓存
flushdb# 清除所有缓存
FLUSHALL
http://www.dtcms.com/wzjs/340321.html

相关文章:

  • 3d建模怎么做网站旋转江苏企业seo推广
  • 淮北论坛最新招聘系统优化的意义
  • 想自己做网站怎么做seo网络优化前景怎么样
  • 做代码的网站网络营销的未来6个发展趋势
  • 网站怎么做扫码微信支付网络营销软件下载
  • 涿州做网站建设seo专业优化公司
  • 广州小程序软件开发seo点击优化
  • p2p网站建设源码培训网站建设
  • 做网站的软件m开头怎么在百度上做广告
  • 物流网信息平台网站优化内容
  • 北京市住房城乡建设委员会网站软文营销的五个步骤
  • 接私活做预算的网站推广普通话的意义50字
  • 西安做网站公司哪家行网站外链购买
  • 如何做一款服装网站深圳最新疫情
  • 全国人社政务服务平台网站seo教程
  • 网站布局规范苏州百度推广
  • 内江规划建设教育培训中心网站网站推广优化排名教程
  • 广州做网站要多少钱今日国内新闻最新消息10条新闻
  • 手机版网站与app免费网络营销推广软件
  • 浙江网站建设推广公司找哪家网上营销培训课程
  • 宁波网站建设详细策划有创意的网络广告案例
  • 素材网站可以做淘宝吗怎样在网上推广
  • 防红短链接生成济南seo网站优化
  • 即墨网站开发如何创建一个网址
  • 59zwd一起做网站seo的培训课程
  • 做网站的技术门槛高吗seo排名软件价格
  • win系统和mac那个做网站好互联网推广中心
  • 牛什么的网站建设电商网课
  • 备案 手机网站百度竞价推广关键词优化
  • 建设网站总结社区营销推广活动方案