-
Notifications
You must be signed in to change notification settings - Fork 28
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
Tuan/homework 2 #30
base: scott/sample-gorm
Are you sure you want to change the base?
Tuan/homework 2 #30
Conversation
…VanTuan_BE-K01 into tuan/homework-2
…VanTuan_BE-K01 into tuan/homework-2
…VanTuan_BE-K01 into tuan/homework-2
23b88d9
to
be0ccae
Compare
cmd/student-manager/main.go
Outdated
// lock | ||
fmt.Println("lock") | ||
err := rd.SetNX(rd.Context(), keyApiPing, id, 5*time.Second).Err() | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can retry till you can get the lock
|
||
fmt.Println("API /ping accessed") | ||
|
||
err = rd.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why need to close redis ?
cmd/student-manager/main.go
Outdated
} | ||
} | ||
|
||
if count == 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 call/60s mean if count =2 then still ok, count > 2 then rate limited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and usually we should check > but not = , because what happen if 2 people call this api at the same time ? then you will get response = 3, even 4 5 6, then you allow them to call this api right ? which is wrong
…VanTuan_BE-K01 into tuan/homework-2
be0ccae
to
817ebf1
Compare
No description provided.