LoginSignup
16
14

More than 5 years have passed since last update.

GCP Cloud Memorystoreを触ってみた

Posted at

GCPでRedis(Cloud Memorystore)が使えるようになったので、触ってみた。

初期設定

image.png

選択項目としては以下のようになってる。

  • Redisバージョン
    • 3.2固定
  • インスタンスの階層
    • 基本
      • 可用性がないが安い
    • 標準
      • 自動フェイルオーバーされる。SLA99.9%
  • ロケーション
    • asia-east1
    • europe-west1
    • us-central1
    • us-east1
    • us-west1
  • インスタンスの容量
    • 1GB〜300GBまで選択可

また詳細設定で、Redisのパラメータを一部指定できる。以下のもの以外は現在は設定できない

  • maxmemory-policy
  • notify-keyspace-events

動作確認

プライベートIPしか振られないので、内部ネットワークからのアクセスしか無理っぽい。
今回はGCEインスタンスを立てて検証する。

色々コマンドを打ってみる

# Redisの動作確認をするので、redis-cliインストール
$ sudo apt-get install redis-tools

# インスタンス情報取得
$ gcloud beta redis instances describe test-instance --region=us-central1
authorizedNetwork: projects/{PROJECT_ID}/global/networks/default
createTime: '2018-05-15T05:41:19.175803Z'
currentLocationId: us-central1-a
displayName: test-instance
host: 10.0.0.3
locationId: us-central1-a
memorySizeGb: 1
name: projects/{PROJECT_ID}/locations/us-central1/instances/test-instance
port: 6379
redisVersion: REDIS_3_2
reservedIpRange: 10.0.0.0/29
state: READY
tier: BASIC

# Redisに入る
$ redis-cli -h 10.0.0.3 -p 6379

# 普通のset/get
10.0.0.3:6379> set test-key "hoge"
OK
10.0.0.3:6379> get test-key
"hoge"

# インクリメント
10.0.0.3:6379> INCR test
(integer) 1
10.0.0.3:6379> INCR test
(integer) 2
10.0.0.3:6379> INCR test
(integer) 3

# Pub/Sub
## Subscribe
10.0.0.3:6379> subscribe test
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "test"
3) (integer) 1
1) "message"
2) "test"
3) "hello!"

## Publish
10.0.0.3:6379> publish test hello!
(integer) 1

# select database
10.0.0.3:6379> select 0
OK
10.0.0.3:6379> set test "hoge"
OK
10.0.0.3:6379> get test
"hoge"
10.0.0.3:6379> select 1
OK
10.0.0.3:6379[1]> get test
(nil)

Redisで出来ることは出来そう

細かいところはあとはこの辺に大体書いてある。ドキュメント充実してるなぁ。
https://cloud.google.com/memorystore/docs/redis/redis-overview

パフォーマンスに関しては後日検証。

16
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14