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: add dev docs for swift sdk #537

Merged
merged 5 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
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
74 changes: 74 additions & 0 deletions docs/cache/develop/sdks/swift/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 Swift
description: Get started really quickly coding using Swift 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 Swift with Momento Cache

If you need to get going quickly with Swift and Momento Cache, 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 CacheClient
This code creates the CacheClient that you will use to call the other methods.

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

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

<SdkExampleCodeBlock language={'swift'} 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={'swift'} snippetId={'API_ListCaches'} />

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

<SdkExampleCodeBlock language={'swift'} 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={'swift'} 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={'swift'} snippetId={'API_Get'} />

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

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

## 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](/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/swift/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_position: 7
title: Momento Swift SDK
pagination_prev: null
sidebar_label: Swift
description: Information about the Momento Swift SDK
---

# Momento Swift SDK

Welcome to the Momento Swift SDK documentation!

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

## Requirements

- [Swift version 5](https://www.swift.org/install/) or higher is required.
- A Momento API key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/).

## Resources

- [Swift SDK cheat sheet](./cheat-sheet.mdx)
- [Swift SDK examples](https://github.com/momentohq/client-sdk-swift/tree/main/Examples): working example projects that illustrate how to use the Swift SDK
- COMING SOON: Observability: Logging and client-side metrics with the Swift SDK
- COMING SOON: Taking your code to prod: configuration and error handling in the Swift 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:
- [Rust](./develop/sdks/rust)
- [Ruby](./develop/sdks/ruby)
- [Elixir](./develop/sdks/elixir)
- [Swift](./develop/sdks/swift)

## 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 @@ -37,6 +37,7 @@ In the following pages, you can learn about caching in general and how to use Mo
- [Rust](./cache/develop/sdks/rust)
- [Ruby](./cache/develop/sdks/ruby)
- [Elixir](./cache/develop/sdks/elixir)
- [Swift](./cache/develop/sdks/swift)

- _If you want to know more about Momento Cache and how it works_, refer to the reference on [Momento Cache concepts](./learn/how-it-works/index.mdx).

Expand Down
54 changes: 54 additions & 0 deletions docs/topics/develop/sdks/swift/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/swift/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_position: 7
title: Momento Topics Swift SDK
pagination_prev: null
sidebar_label: Swift
description: Information about the Momento Swift SDK
---

# Momento Topics Swift SDK

Welcome to the Momento Swift SDK documentation!

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

## Requirements

- [Swift version 5](https://www.swift.org/install/) or higher is required.
- A Momento API key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/).

## Resources

- [Swift SDK cheat sheet](./cheat-sheet.mdx)
- [Swift SDK examples](https://github.com/momentohq/client-sdk-swift/tree/main/Examples): working example projects that illustrate how to use the Swift SDK
- COMING SOON: Observability: Logging and client-side metrics with the Swift SDK
- COMING SOON: Taking your code to prod: configuration and error handling in the Swift 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 @@ -368,7 +368,7 @@ const config = {
],
},
prism: {
additionalLanguages: ["java", "rust", "csharp", "php", "elixir"],
additionalLanguages: ["java", "rust", "csharp", "php", "elixir", "swift"],
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 Swift
description: Get started really quickly coding using Swift 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 Swift with Momento Cache

If you need to get going quickly with Swift and Momento Cache, 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 CacheClient
This code creates the CacheClient that you will use to call the other methods.

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

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

<SdkExampleCodeBlock language={'swift'} 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={'swift'} snippetId={'API_ListCaches'} />

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

<SdkExampleCodeBlock language={'swift'} 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={'swift'} 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={'swift'} snippetId={'API_Get'} />

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

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

## 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](/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 Swift SDK
pagination_prev: null
sidebar_label: Swift
description: Information about the Momento Swift SDK
---

# Momento Swift SDK

Welcome to the Momento Swift SDK documentation!

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

## Requirements

- [Swift version 5](https://www.swift.org/install/) or higher is required.
- A Momento API key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/).

## Resources

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

## Integrations

COMING SOON
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ CLIをローカル(Linux, Windows, Mac)にインストールすることも可
- [Rust](./develop/sdks/rust)
- [Ruby](./develop/sdks/ruby)
- [Elixir](./develop/sdks/elixir)
- [Swift](./develop/sdks/swift)

## FAQ

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Momento キャッシュと[Momento トピックス](./../topics/index.md) は次
- [Rust](./cache/develop/sdks/rust)
- [Ruby](./cache/develop/sdks/ruby)
- [Elixir](./cache/develop/sdks/elixir)
- [Swift](./cache/develop/sdks/swift)

- Momento キャッシュについてもっと詳しく、どの様に動作するのかを知りたい方は、のセクション、特に[Momento キャッシュの概念](./learn/how-it-works/index.mdx)に関する部分をご覧下さい。

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'} />
pgautier404 marked this conversation as resolved.
Show resolved Hide resolved

## 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
Loading