使用Springboot+redis+Vue实现秒杀的一个Demo
1、Redis简介
Redis是一个开源的key-value存储系统。
Redis的五种基本类型:String(字符串),list(链表),set(集合),zset(有序集合),hash,stream(Redis5.0后的新数据结构)
这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。
Redis的应用场景为配合关系型数据库做高速缓存,降低数据库IO
需要注意的是,Redis是单线程的,如果一次批量处理命令过多,会造成Redis阻塞或网络拥塞(传输数据量大)
2、实现代码

pom.xml
4.0.0 org.springframework.boot spring-boot-starter-parent 2.2.1.RELEASE org.example seckill 1.0-SNAPSHOT 1.8 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test 2.2.1.RELEASE test org.springframework.boot spring-boot-starter-data-redis org.apache.commons commons-pool2 2.6.0 com.alibaba fastjson 1.2.24 org.springframework.boot spring-boot-maven-plugin true
application.properties.xml
#Redis服务器地址
spring.redis.host=192.168.1.2
#Redis服务器连接端口
spring.redis.port=6379
#Redis数据库索引(默认为0)
spring.redis.database=0
#连接超时时间(毫秒)
spring.redis.timeout=1800000
#连接池最大连接数(使用负值表示没有限制)
spring.redis.lettuce.pool.max-active=20
#最大阻塞等待时间(负数表示没限制)
spring.redis.lettuce.pool.ma
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
