Skip to content

Commit

Permalink
chore: adding dart docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pgautier404 committed Jan 13, 2024
1 parent 3f3f88e commit 8026701
Show file tree
Hide file tree
Showing 23 changed files with 450 additions and 6 deletions.
74 changes: 74 additions & 0 deletions docs/cache/develop/sdks/dart/cheat-sheet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
sidebar_position: 1
sidebar_label: Cheat Sheet
sidebar_class_name: sidebar-item-swift
title: Cheat Sheet for Dart
description: Get started really quickly coding using Dart with Momento Cache
---

import { SdkExampleCodeBlock } from "@site/src/components/SdkExampleCodeBlock";
// This import is necessary even though it looks like it's un-used; The inject-example-code-snippet
// plugin will transform instances of SdkExampleCodeBlock to SdkExampleCodeBlockImpl
import { SdkExampleCodeBlockImpl } from "@site/src/components/SdkExampleCodeBlockImpl";

# Cheat Sheet for Dart with Momento Cache

If you need to get going quickly with Dart and Momento Cache, this page contains the basic API calls you'll need. [Check the Dart SDK examples](https://github.com/momentohq/client-sdk-dart/tree/main/examples) for complete, working code samples.

## Install the Momento SDK

The latest version of the Momento Dart SDK is available on GitHub: [momentohq/client-sdk-dart](https://github.com/momentohq/client-sdk-dart).

## Get your Momento API key

You'll need a Momento API key. You can get one from the [Momento Web Console](https://console.gomomento.com/).
Once you have your token, store it in an environment variable so that the Momento client can consume it:

```
export MOMENTO_API_KEY=<your api key here>
```

**Note**: it is best practice to put the API key into something like AWS Secret Manager or GCP Secret Manager instead of an environment variable for enhanced security, but we are using one here for demo purposes.

## Set up a CacheClient
This code creates the CacheClient that you will use to call the other methods.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_InstantiateCacheClient'} />

## Create a new cache in Momento Cache
Use this function to create a new cache in your account.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_CreateCache'} />

## List the names of existing caches in your account
A simple list of the names of caches for the account.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_ListCaches'} />

## Delete a cache
Use this function to delete a cache from your account.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_DeleteCache'} />

## Write an item to a cache
A simple example of doing a set operation. In the CacheClient.set() call, the TTL is optional. If you did pass it in, this would override the default TTL value set with the client connection object.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_Set'} />

## Read an item from a cache
This is an example of a simple read operation to get an item from a cache.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_Get'} />

## Delete an item from a cache
This is an example of deleting an item from a cache.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_Delete'} />

## Running the code

You can find complete, working examples in the [Dart SDK GitHub repo examples directory](https://github.com/momentohq/client-sdk-dart/tree/main/examples).

:::info
Beyond these basic API calls check out the [API reference page](/cache/develop/api-reference/index.mdx) for more information on the full assortment of Momento API calls.
:::
29 changes: 29 additions & 0 deletions docs/cache/develop/sdks/dart/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_position: 7
title: Momento Dart SDK
pagination_prev: null
sidebar_label: Dart
description: Information about the Momento Dart SDK
---

# Momento Swift SDK

Welcome to the Momento Dart SDK documentation!

The Momento Dart SDK and source code are available via GitHub: [momentohq/client-sdk-swift](https://github.com/momentohq/client-sdk-swift).

## Requirements

- [Dart version 3](https://dart.dev/get-dart) or higher is required.
- A Momento API key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/).

## Resources

- [Dart SDK cheat sheet](./cheat-sheet.mdx)
- [Dart SDK examples](https://github.com/momentohq/client-sdk-dart/tree/main/examples): working example projects that illustrate how to use the Dart SDK
- COMING SOON: Observability: Logging and client-side metrics with the Dart SDK
- COMING SOON: Taking your code to prod: configuration and error handling in the Dart SDK

## Integrations

COMING SOON
1 change: 1 addition & 0 deletions docs/cache/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ We currently have the following SDK languages available:
- [Ruby](./develop/sdks/ruby)
- [Elixir](./develop/sdks/elixir)
- [Swift](./develop/sdks/swift)
- [Dart](./develop/sdks/dart)

## FAQ

Expand Down
1 change: 1 addition & 0 deletions docs/cache/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ In the following pages, you can learn about caching in general and how to use Mo
- [Ruby](./cache/develop/sdks/ruby)
- [Elixir](./cache/develop/sdks/elixir)
- [Swift](./cache/develop/sdks/swift)
- [Dart](./develop/sdks/dart)

- _Looking for Momento icons for your architecture diagrams?_ Download [Momento_Architecture_Icons.zip](@site/static/img/icons/Momento_Architecture_Icons.zip).

Expand Down
54 changes: 54 additions & 0 deletions docs/topics/develop/sdks/dart/cheat-sheet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
sidebar_position: 1
sidebar_label: Topics Cheat Sheet
sidebar_class_name: sidebar-item-swift
title: Topics cheat sheet for Swift
description: Get started really quickly coding using Swift with Momento Topics
---

import { SdkExampleCodeBlock } from "@site/src/components/SdkExampleCodeBlock";
// This import is necessary even though it looks like it's un-used; The inject-example-code-snippet
// plugin will transform instances of SdkExampleCodeBlock to SdkExampleCodeBlockImpl
import { SdkExampleCodeBlockImpl } from "@site/src/components/SdkExampleCodeBlockImpl";

# Cheat Sheet for Swift with Momento Topics

If you need to get going quickly with Swift and Momento Topics, this page contains the basic API calls you'll need. [Check the Swift SDK examples](https://github.com/momentohq/client-sdk-swift/tree/main/Examples) for complete, working code samples.

## Install the Momento SDK

The latest version of the Momento Swift SDK is available on GitHub: [momentohq/client-sdk-swift](https://github.com/momentohq/client-sdk-swift).

## Get your Momento API key

You'll need a Momento API key. You can get one from the [Momento Web Console](https://console.gomomento.com/).
Once you have your token, store it in an environment variable so that the Momento client can consume it:

```
export MOMENTO_API_KEY=<your api key here>
```

**Note**: it is best practice to put the API key into something like AWS Secret Manager or GCP Secret Manager instead of an environment variable for enhanced security, but we are using one here for demo purposes.

## Set up a TopicClient
This code creates the TopicClient that you will use to interact with your pub/sub topic.

<SdkExampleCodeBlock language={'swift'} snippetId={'API_InstantiateTopicClient'} />

## Publish a message to a topic
This is an example of publishing a message to a topic called "topic", then catching the return value to check if the publish was successful.

<SdkExampleCodeBlock language={'swift'} snippetId={'API_TopicPublish'} />

## Subscribe to a topic
This is an example of subscribing to a topic called "topic", then catching the return value to check if it was successful. If a subscription was received, a `for try await` loop is used to asynchronously receive and print the messages that are published to this topic.

<SdkExampleCodeBlock language={'swift'} snippetId={'API_TopicSubscribe'} />

## Running the code

You can find complete, working examples in the [Swift SDK GitHub repo examples directory](https://github.com/momentohq/client-sdk-swift/tree/main/examples).

:::info
Beyond these basic API calls check out the [API reference page](./../../api-reference) for more information on the full assortment of Momento API calls.
:::
29 changes: 29 additions & 0 deletions docs/topics/develop/sdks/dart/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_position: 7
title: Momento Topics Dart SDK
pagination_prev: null
sidebar_label: Dart
description: Information about the Momento Dart SDK
---

# Momento Topics Dart SDK

Welcome to the Momento Dart SDK documentation!

The Momento Dart SDK and source code are available via GitHub: [momentohq/client-sdk-swift](https://github.com/momentohq/client-sdk-dart).

## Requirements

- [Dart version 3](https://dart.dev/get-dart) or higher is required.
- A Momento API key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/).

## Resources

- [Dart SDK cheat sheet](./cheat-sheet.mdx)
- [Dart SDK examples](https://github.com/momentohq/client-sdk-dart/tree/main/examples): working example projects that illustrate how to use the Dart SDK
- COMING SOON: Observability: Logging and client-side metrics with the Dart SDK
- COMING SOON: Taking your code to prod: configuration and error handling in the Dart SDK

## Integrations

COMING SOON
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const config = {
],
},
prism: {
additionalLanguages: ["java", "rust", "csharp", "php", "elixir", "swift"],
additionalLanguages: ["java", "rust", "csharp", "php", "elixir", "swift", "dart"],
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
sidebar_position: 1
sidebar_label: Cheat Sheet
sidebar_class_name: sidebar-item-swift
title: Cheat Sheet for Dart
description: Get started really quickly coding using Dart with Momento Cache
---

import { SdkExampleCodeBlock } from "@site/src/components/SdkExampleCodeBlock";
// This import is necessary even though it looks like it's un-used; The inject-example-code-snippet
// plugin will transform instances of SdkExampleCodeBlock to SdkExampleCodeBlockImpl
import { SdkExampleCodeBlockImpl } from "@site/src/components/SdkExampleCodeBlockImpl";

# Cheat Sheet for Dart with Momento Cache

If you need to get going quickly with Dart and Momento Cache, this page contains the basic API calls you'll need. [Check the Dart SDK examples](https://github.com/momentohq/client-sdk-dart/tree/main/examples) for complete, working code samples.

## Install the Momento SDK

The latest version of the Momento Dart SDK is available on GitHub: [momentohq/client-sdk-dart](https://github.com/momentohq/client-sdk-dart).

## Get your Momento API key

You'll need a Momento API key. You can get one from the [Momento Web Console](https://console.gomomento.com/).
Once you have your token, store it in an environment variable so that the Momento client can consume it:

```
export MOMENTO_API_KEY=<your api key here>
```

**Note**: it is best practice to put the API key into something like AWS Secret Manager or GCP Secret Manager instead of an environment variable for enhanced security, but we are using one here for demo purposes.

## Set up a CacheClient
This code creates the CacheClient that you will use to call the other methods.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_InstantiateCacheClient'} />

## Create a new cache in Momento Cache
Use this function to create a new cache in your account.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_CreateCache'} />

## List the names of existing caches in your account
A simple list of the names of caches for the account.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_ListCaches'} />

## Delete a cache
Use this function to delete a cache from your account.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_DeleteCache'} />

## Write an item to a cache
A simple example of doing a set operation. In the CacheClient.set() call, the TTL is optional. If you did pass it in, this would override the default TTL value set with the client connection object.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_Set'} />

## Read an item from a cache
This is an example of a simple read operation to get an item from a cache.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_Get'} />

## Delete an item from a cache
This is an example of deleting an item from a cache.

<SdkExampleCodeBlock language={'dart'} snippetId={'API_Delete'} />

## Running the code

You can find complete, working examples in the [Dart SDK GitHub repo examples directory](https://github.com/momentohq/client-sdk-dart/tree/main/examples).

:::info
Beyond these basic API calls check out the [API reference page](/cache/develop/api-reference/index.mdx) for more information on the full assortment of Momento API calls.
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_position: 7
title: Momento Dart SDK
pagination_prev: null
sidebar_label: Dart
description: Information about the Momento Dart SDK
---

# Momento Swift SDK

Welcome to the Momento Dart SDK documentation!

The Momento Dart SDK and source code are available via GitHub: [momentohq/client-sdk-swift](https://github.com/momentohq/client-sdk-swift).

## Requirements

- [Dart version 3](https://dart.dev/get-dart) or higher is required.
- A Momento API key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/).

## Resources

- [Dart SDK cheat sheet](./cheat-sheet.mdx)
- [Dart SDK examples](https://github.com/momentohq/client-sdk-dart/tree/main/examples): working example projects that illustrate how to use the Dart SDK
- COMING SOON: Observability: Logging and client-side metrics with the Dart SDK
- COMING SOON: Taking your code to prod: configuration and error handling in the Dart SDK

## Integrations

COMING SOON
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ CLI の最新バージョンとインストール方法、使い方は [この
- [Ruby](./develop/sdks/ruby)
- [Elixir](./develop/sdks/elixir)
- [Swift](./develop/sdks/swift)
- [Dart](./develop/sdks/dart)

## FAQ

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Momento Cacheは、以下のクラウドプロバイダーおよびリージョ
- [Ruby](./cache/develop/sdks/ruby)
- [Elixir](./cache/develop/sdks/elixir)
- [Swift](./cache/develop/sdks/swift)
- [Dart](./cache/develop/sdks/dart)

- アーキテクチャ図用のMomentoのアイコンをお探しですか?[Momento_Architecture_Icons.zip](@site/static/img/icons/Momento_Architecture_Icons.zip)をダウンロードしてください。

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
sidebar_position: 1
sidebar_label: Topics Cheat Sheet
sidebar_class_name: sidebar-item-swift
title: Topics cheat sheet for Swift
description: Get started really quickly coding using Swift with Momento Topics
---

import { SdkExampleCodeBlock } from "@site/src/components/SdkExampleCodeBlock";
// This import is necessary even though it looks like it's un-used; The inject-example-code-snippet
// plugin will transform instances of SdkExampleCodeBlock to SdkExampleCodeBlockImpl
import { SdkExampleCodeBlockImpl } from "@site/src/components/SdkExampleCodeBlockImpl";

# Cheat Sheet for Swift with Momento Topics

If you need to get going quickly with Swift and Momento Topics, this page contains the basic API calls you'll need. [Check the Swift SDK examples](https://github.com/momentohq/client-sdk-swift/tree/main/Examples) for complete, working code samples.

## Install the Momento SDK

The latest version of the Momento Swift SDK is available on GitHub: [momentohq/client-sdk-swift](https://github.com/momentohq/client-sdk-swift).

## Get your Momento API key

You'll need a Momento API key. You can get one from the [Momento Web Console](https://console.gomomento.com/).
Once you have your token, store it in an environment variable so that the Momento client can consume it:

```
export MOMENTO_API_KEY=<your api key here>
```

**Note**: it is best practice to put the API key into something like AWS Secret Manager or GCP Secret Manager instead of an environment variable for enhanced security, but we are using one here for demo purposes.

## Set up a TopicClient
This code creates the TopicClient that you will use to interact with your pub/sub topic.

<SdkExampleCodeBlock language={'swift'} snippetId={'API_InstantiateTopicClient'} />

## Publish a message to a topic
This is an example of publishing a message to a topic called "topic", then catching the return value to check if the publish was successful.

<SdkExampleCodeBlock language={'swift'} snippetId={'API_TopicPublish'} />

## Subscribe to a topic
This is an example of subscribing to a topic called "topic", then catching the return value to check if it was successful. If a subscription was received, a `for try await` loop is used to asynchronously receive and print the messages that are published to this topic.

<SdkExampleCodeBlock language={'swift'} snippetId={'API_TopicSubscribe'} />

## Running the code

You can find complete, working examples in the [Swift SDK GitHub repo examples directory](https://github.com/momentohq/client-sdk-swift/tree/main/examples).

:::info
Beyond these basic API calls check out the [API reference page](./../../api-reference) for more information on the full assortment of Momento API calls.
:::
Loading

0 comments on commit 8026701

Please sign in to comment.