safe_chan

command
v0.0.0-...-9dec8c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

*

  • 微博抢红包
  • 两个步骤
  • 1 抢红包,设置红包总金额,红包个数,返回抢红包的地址
  • GET /set?uid=1&money=100&num=100
  • 2 抢红包,先到先得,随机得到红包金额
  • GET /get?id=1&uid=1
  • 注意:
  • 线程安全1,红包列表 packageList map 改用线程安全的 sync.Map
  • 线程安全2,红包里面的金额切片 packageList map[uint32][]uint 并发读写不安全,虽然不会报错
  • 改进:使用 channel 来更新
  • 并发抢红包:wrk -t10 -c10 -d5 "http://localhost:8080/get?uid=1&id=947622073"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL