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

Ping reports successful on empty hosts #179

Open
dimitrovvlado opened this issue Aug 18, 2024 · 0 comments
Open

Ping reports successful on empty hosts #179

dimitrovvlado opened this issue Aug 18, 2024 · 0 comments

Comments

@dimitrovvlado
Copy link

I noticed the following code works fine:

c := *memcache.New()
err := c.Ping()
if err != nil {
    panic(err)
}
fmt.Println("No problem")

At first glance it looks okay - no hosts to ping means no errors, but there are a couple of problems:

  1. An actual client is constructed which is essentially non functional. Furthermore New() doesn't return an error and the only way to verify if the client is in fact functional is to run another operation.
  2. If we add further statements such as err = c.Add(&memcache.Item{Key: "k", Value: []byte("v")}) those will fail which leads to inconsistent behaviour in the API.

I suppose there are 2 ways to fix that - either change Ping() to check the hosts size, or change New() to do that and return an error

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

1 participant