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

Tuan/homework 2 #30

Open
wants to merge 8 commits into
base: scott/sample-gorm
Choose a base branch
from

Conversation

tuanpham197
Copy link

No description provided.

// lock
fmt.Println("lock")
err := rd.SetNX(rd.Context(), keyApiPing, id, 5*time.Second).Err()
if err != nil {
Copy link
Collaborator

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()
Copy link
Collaborator

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 ?

}
}

if count == 2 {
Copy link
Collaborator

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

Copy link
Collaborator

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

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

Successfully merging this pull request may close these issues.

2 participants