java design time-limited spike activity (personal ideas, welcome to discuss)

Let’s not talk about the server cluster, configure a few redis, and then add a redis cluster, master-slave replication, assuming a total of 200 items, 1 o’clock in the afternoon, the time limit is 10 minutes, my idea is to set a key in redis, this The key (A) is 200. When there is a request from one point to one point, get the requested user ID and insert this ID plus the naming rules of the event into redis, and then put A-1 until A is 0, then reject all requests, and reject all requests when the time expires. To sum up, the method is probably as follows: first get key-A, if A is greater than 0, then go to get the ID of this user, and add this activity The naming rules are stored in redis, and A-1 is returned, and the snap-up is successful, else, it returns that the goods have been snapped up. Probably the idea is like this, time control is realized in the foreground!
This is just a rookie's idea, welcome to correct the inadequacies......

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325550056&siteId=291194637