Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

预减库存preReduceProdStock的问题 #12

Open
wangjia2016 opened this issue Nov 5, 2020 · 1 comment
Open

预减库存preReduceProdStock的问题 #12

wangjia2016 opened this issue Nov 5, 2020 · 1 comment

Comments

@wangjia2016
Copy link

image

redisTemplate.opsForValue().decrement(prodId,number)

1、利用redis的原子性减库存 会更合适吧

2、这里的预减库存,多个jvm实例的情况下,synchronized应该是没有锁住的,是用类似redisson 分布式锁来控制

@zlq0527
Copy link

zlq0527 commented Feb 8, 2023

  1. 他Redis里放的不是库存个数,而是商品Id对应的商品对象,所以它使用了这种方式, 如果他Redis 里放的是商品ID,商品库存 就是用Redis的Decr命令更合适。
  2. 这个问题很好, 他这个秒杀应该是单机的 单实例 syn也暂时够用,如果上分布式 就要用redis的分布式锁了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants