Skip to content

Commit

Permalink
Initial version 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
brunopadz committed Mar 25, 2022
0 parents commit 1cce78d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# memcached-ok

Simple app to test connection to memcached using SASL authentication.

## How to use

[Download](https://github.com/brunopadz/memcached-ok/releases) the binary for your system.

The following ENV VARs must be exported:

- `MEMCACHED_SERVER`
- `MEMCACHED_USERNAME`
- `MEMCACHED_PASSWORD`

### Example

```shell
$ MEMCACHED_SERVER=localhost:11211 MEMCACHED_USERNAME=foo MEMCACHED_PASSWORD=bar memcached-ok
```
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module memcached-ok

go 1.16

require github.com/memcachier/mc/v3 v3.0.3
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/memcachier/mc/v3 v3.0.3 h1:qii+lDiPKi36O4Xg+HVKwHu6Oq+Gt17b+uEiA0Drwv4=
github.com/memcachier/mc/v3 v3.0.3/go.mod h1:GzjocBahcXPxt2cmqzknrgqCOmMxiSzhVKPOe90Tpug=
25 changes: 25 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
"github.com/memcachier/mc/v3"
"os"
)

func main() {

m := mc.NewMC(os.Getenv("MEMCACHED_SERVER"), os.Getenv("MEMCACHED_USERNAME"), os.Getenv("MEMCACHED_PASSWORD"))
defer m.Quit()

s, err := m.Stats()
if err != nil {
fmt.Println("Couldn't connect to memcached:", err)
os.Exit(1)
}

for _, d := range s {
if v, ok := d["version"]; ok {
fmt.Println("Connection to memcached is ok, memcached version:", v)
}
}
}

0 comments on commit 1cce78d

Please sign in to comment.