設定用戶端程式庫

本頁面說明如何安裝 Memorystore for Redis API 適用的用戶端程式庫,以便您使用自己選擇的語言連線至 API。

安裝用戶端程式庫

C++

如要進一步瞭解此用戶端程式庫的需求和安裝依附元件,請參閱「設定 C++ 開發環境」。

C#

在 Visual Studio 中安裝 Google.Cloud.Redis.V1 套件

Go

go get cloud.google.com/go/redis/apiv1

Java

如果您使用 Maven,請在 pom.xml 檔案中加入以下指令:

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-redis</artifactId>
    <version>0.62.0-alpha</version>
</dependency>

如果您使用 Gradle,請在依附元件中加入以下指令:

compile 'com.google.cloud:google-cloud-redis:0.62.0-alpha'

如果您使用 SBT,請在依附元件中加入以下指令:

libraryDependencies += "com.google.cloud" % "google-cloud-redis" % "0.62.0-alpha"

如果您使用的是 VS Code、IntelliJ 或 Eclipse,可以使用下列 IDE 外掛程式將用戶端程式庫加入專案中:

外掛程式提供其他功能,像是服務帳戶的金鑰管理功能等等。詳情請參閱個別外掛程式的說明文件。

Node.js

npm install @google-cloud/redis

PHP

composer require google/cloud-redis

Python

如要進一步瞭解如何設定 Python 開發環境,請參閱 Python 開發環境設定指南
pip install --upgrade google-cloud-redis

Ruby

gem install google-cloud-redis

設定驗證

  1. After installing the Google Cloud CLI, initialize it by running the following command:

    gcloud init

    If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  2. If you're using a local shell, then create local authentication credentials for your user account:

    gcloud auth application-default login

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

    系統隨即會顯示登入畫面。登入後,憑證會儲存在 ADC 使用的本機憑證檔案中。

其他資源