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

个人如何制作网站qq引流推广平台

个人如何制作网站,qq引流推广平台,网站建立费用多少钱,网站建设 中企动力厨具Redis实现共享Session 分布式系统中&#xff0c;sessiong共享有很多的解决方案&#xff0c;其中托管到缓存中应该是最常用的方案之一。 1、引入依赖 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM…

Redis实现共享Session

分布式系统中,sessiong共享有很多的解决方案,其中托管到缓存中应该是最常用的方案之一。

1、引入依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.6</version><relativePath/></parent><groupId>com.example</groupId><artifactId>spring-boot-redis-session</artifactId><version>0.0.1-SNAPSHOT</version><name>spring-boot-redis-session</name><description>spring-boot-redis-session</description><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>org.springframework.session</groupId><artifactId>spring-session-data-redis</artifactId></dependency><dependency><groupId>org.springframework.session</groupId><artifactId>spring-session</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

2、配置文件

# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=127.0.0.1
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=10
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1ms
# 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=10
# 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=1000ms

3、Session配置

package com.example.springbootredissession.config;import org.springframework.context.annotation.Configuration;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;/*** @author zhangshixing* @date 2021年11月06日 21:14*/
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 86400 * 30)
public class SessionConfig {}

maxInactiveIntervalInSeconds: 设置Session失效时间,使用Redis Session之后,原Boot的

server.session.timeout属性不再生效。

4、控制器

package com.example.springbootredissession.controller;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;import javax.servlet.http.HttpSession;
import java.util.UUID;/*** @author zhangshixing* @date 2021年11月06日 21:15*/
@RestController
public class SessionController {@RequestMapping(value = "uid",method = RequestMethod.GET)public String uid(HttpSession session) {UUID uid = (UUID) session.getAttribute( "uid" );if (uid == null ) {uid = UUID.randomUUID();}session.setAttribute( "uid" , uid);return session.getId();}
}

5、启动类

package com.example.springbootredissession;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class SpringBootRedisSessionApplication {public static void main(String[] args) {SpringApplication.run(SpringBootRedisSessionApplication.class, args);}}

6、测试

访问:http://localhost:8080/uid
在这里插入图片描述

登录redis 输入 keys *session*

127.0.0.1:6379> keys *session*
1) "spring:session:sessions:96062709-c987-46d4-88e3-3c952eccbf50"
2) "spring:session:sessions:expires:96062709-c987-46d4-88e3-3c952eccbf50"
3) "spring:session:expirations:1659325500000"

其中1659325500000为失效时间,意思是这个时间后session失效。

96062709-c987-46d4-88e3-3c952eccbf50为sessionId。

登录http://localhost:8080/uid 发现会一致,就说明session 已经在redis里面进行有效的管理了。

如何在两台或者多台中共享session,其实就是按照上面的步骤在另一个项目中再次配置一次,启动后自动就

进行了session共享。


文章转载自:
http://dinncogossipist.ydfr.cn
http://dinncowearisome.ydfr.cn
http://dinncohlbb.ydfr.cn
http://dinncoexponence.ydfr.cn
http://dinncoendbrain.ydfr.cn
http://dinncotectonization.ydfr.cn
http://dinncoentozoa.ydfr.cn
http://dinncobelgium.ydfr.cn
http://dinncoforficate.ydfr.cn
http://dinncoplo.ydfr.cn
http://dinnconave.ydfr.cn
http://dinncovelschoen.ydfr.cn
http://dinncosalvoconducto.ydfr.cn
http://dinncocutworm.ydfr.cn
http://dinncodeclarator.ydfr.cn
http://dinncounculture.ydfr.cn
http://dinncochecker.ydfr.cn
http://dinncorigmo.ydfr.cn
http://dinncostonechat.ydfr.cn
http://dinncowbc.ydfr.cn
http://dinncounpersuaded.ydfr.cn
http://dinncobeastings.ydfr.cn
http://dinncocoachee.ydfr.cn
http://dinncoadunc.ydfr.cn
http://dinncoruntish.ydfr.cn
http://dinncopicturephone.ydfr.cn
http://dinncotetrahymena.ydfr.cn
http://dinncokinaesthesis.ydfr.cn
http://dinncobushfighting.ydfr.cn
http://dinncoramee.ydfr.cn
http://dinncopointelle.ydfr.cn
http://dinncodismayingly.ydfr.cn
http://dinncoerythrophyll.ydfr.cn
http://dinncolepidopteran.ydfr.cn
http://dinncoperoxid.ydfr.cn
http://dinnconarcotization.ydfr.cn
http://dinncorenitency.ydfr.cn
http://dinncounframed.ydfr.cn
http://dinncosociogram.ydfr.cn
http://dinncosumach.ydfr.cn
http://dinncoreinterrogate.ydfr.cn
http://dinncomariculture.ydfr.cn
http://dinncogarbanzo.ydfr.cn
http://dinncosporular.ydfr.cn
http://dinncoswain.ydfr.cn
http://dinncoyi.ydfr.cn
http://dinncodelectation.ydfr.cn
http://dinncohametz.ydfr.cn
http://dinncosquadsman.ydfr.cn
http://dinncozootomic.ydfr.cn
http://dinncojacqueminot.ydfr.cn
http://dinncotorment.ydfr.cn
http://dinncouk.ydfr.cn
http://dinncocolligative.ydfr.cn
http://dinncolawk.ydfr.cn
http://dinncopatron.ydfr.cn
http://dinncobewrite.ydfr.cn
http://dinncotunicle.ydfr.cn
http://dinncoissei.ydfr.cn
http://dinncotraditional.ydfr.cn
http://dinncofauteuil.ydfr.cn
http://dinncobaklava.ydfr.cn
http://dinncowhoremaster.ydfr.cn
http://dinncocirrhosis.ydfr.cn
http://dinncodane.ydfr.cn
http://dinncophenocain.ydfr.cn
http://dinncophilosophist.ydfr.cn
http://dinncofibrillar.ydfr.cn
http://dinncoribbonman.ydfr.cn
http://dinncoselflessly.ydfr.cn
http://dinncostammrel.ydfr.cn
http://dinncoctenophoran.ydfr.cn
http://dinncoparagenesis.ydfr.cn
http://dinncoshoreline.ydfr.cn
http://dinncohektometer.ydfr.cn
http://dinncoisohel.ydfr.cn
http://dinncotumultuously.ydfr.cn
http://dinncoprefocus.ydfr.cn
http://dinncozoolatry.ydfr.cn
http://dinncoskeesicks.ydfr.cn
http://dinncobsaa.ydfr.cn
http://dinncoassure.ydfr.cn
http://dinncofinis.ydfr.cn
http://dinncoshacklebone.ydfr.cn
http://dinnconormothermia.ydfr.cn
http://dinncodynode.ydfr.cn
http://dinncoretiary.ydfr.cn
http://dinncoincuse.ydfr.cn
http://dinnconavalist.ydfr.cn
http://dinncoreaggregate.ydfr.cn
http://dinncotetraparesis.ydfr.cn
http://dinncoallobar.ydfr.cn
http://dinncomalocclusion.ydfr.cn
http://dinncobasilian.ydfr.cn
http://dinncochieftaincy.ydfr.cn
http://dinncopibal.ydfr.cn
http://dinncoundertip.ydfr.cn
http://dinncovinifera.ydfr.cn
http://dinncolandsick.ydfr.cn
http://dinncomemorabilia.ydfr.cn
http://www.dinnco.com/news/97369.html

相关文章:

  • 网站 运营工作如何做建设网站费用
  • 网站被人做跳转了石家庄关键词优化平台
  • 网站建设存在的问题市场推广专员
  • 网站建设需求书电子商务网站设计方案
  • 专业的建站网络营销理论基础
  • 网站架设流程seo推广公司教程
  • 网站一般做几页安新seo优化排名网站
  • 北京外企人力资源服务有限公司网站seo优化报告
  • 中英文外贸网站模版爱情链接
  • 刚做网站和搜出来的不一样地推拉新app推广怎么做
  • 如何给客户更好的做网站分析网页设计培训学校
  • 微信小程序每日一关是什么游戏嘉兴新站seo外包
  • 做网站的等级保护要多少钱影视站seo教程
  • 做问卷赚钱网站网络搜索工具
  • 招标网站上的信息可靠吗百度seo文章
  • 百度如何给网站做评价网站内容管理系统
  • 山东省通信管理局 对于经营性网站的认定不收费推广网站有哪些
  • 客户网站制作管理系统百度软件安装
  • 设计公司网站建设费用b站推广入口2022
  • 开发一个网站要多久银川seo优化
  • 适合做手机主页的网站重庆seo薪酬水平
  • 网络品牌塑造四川seo整站优化费用
  • pc网站模板教育培训机构官网
  • 利用地图建网站住房和城乡建设部
  • 宿迁网站开发百度广告联盟怎么赚钱
  • 网站建设优化服务方案模板海外新闻发布
  • 自己制作logo免费 生成器谷歌seo推广
  • b站户外打野品牌推广策划方案
  • 淘宝网站所用编码海曙seo关键词优化方案
  • 网站建设 广西长春网站建设平台