設定用戶端程式庫

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

安裝用戶端程式庫

C++

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

C#

在 Visual Studio 中安裝 Google.Cloud.Memcache.V1 套件。詳情請參閱 Google Cloud .NET Memcached 安裝說明文件。

Go

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

Java

如果您搭配使用 Maven 與 BOM,請將下列指令新增至 pom.xml 檔案

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>libraries-bom</artifactId>
      <version>20.8.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
 
<dependencies>
  <dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-memcache</artifactId>
  </dependency>

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

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-memcache</artifactId>
  <version>0.2.1</version>
</dependency>

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

  compile 'com.google.cloud:google-cloud-memcache:0.2.1'

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

  libraryDependencies += "com.google.cloud" % "google-cloud-memcache" % "0.2.1"

Node.js

npm install @google-cloud/memcache

Python

如要進一步瞭解如何設定 Python 開發環境,請參閱 Python 開發環境設定指南

Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-memcache
Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-memcache

設定驗證

  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 使用的本機憑證檔案中。

其他資源