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

chore: Update README.md #295

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ Check out full working code in the [examples](./examples/README.md) directory of
### Installation

```bash
# Create a new module directory
mkdir my-example-project
cd ./my-example-project

# Create a module with go.mod file in the directory.
# See https://go.dev/doc/modules/gomod-ref for full docs on go mod
go mod init example/my-example-project

# Get the SDK.
go get github.com/momentohq/client-sdk-go
```

Expand Down Expand Up @@ -66,7 +75,7 @@ func main() {
itemDefaultTTLSeconds = 60
)

// Initializes Momento
// Initializes Momento CacheClient
client, err := momento.NewCacheClient(
config.LaptopLatest(),
credentialProvider,
Expand All @@ -76,7 +85,7 @@ func main() {
panic(err)
}

// Create Cache
// Create a new cache
_, err = client.CreateCache(ctx, &momento.CreateCacheRequest{
CacheName: cacheName,
})
Expand Down Expand Up @@ -105,7 +114,8 @@ func main() {
if err != nil {
panic(err)
}


// Check to see if you got a cache hit or a cache miss.
switch r := resp.(type) {
case *responses.GetHit:
log.Printf("Lookup resulted in cache HIT. value=%s\n", r.ValueString())
Expand All @@ -130,7 +140,7 @@ Here's a quick example:
```go
switch r := resp.(type) {
case *momento.GetHit:
log.Printf("Lookup resulted in cahce HIT. value=%s\n", r.ValueString())
log.Printf("Lookup resulted in cache HIT. value=%s\n", r.ValueString())
default:
// you can handle other cases via pattern matching in other `switch case`, or a default case
// via the `default` block. For each return value your IDE should be able to give you code
Expand Down