【Redis】1. redission分布式锁
模拟扣库存服务,不加任何锁: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> package com.hknetty.redis; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class IndexContrpller { @Autowired private StringRedisTemplate stringRedisTemplate; @GetMapping("/deduct_stock") public String deductStock() { //商品ID String