Skip to content

cloudymoma/Memorystore-pubsub-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MemoryStore for Redis pub/sub demo

Provision

  1. Create MemoryStore for Redis deployment in GCP console

  2. View the service information

gcloud redis instances describe my-redis --region=us-central1
  1. Make notes of the IP address along with port number
host: xx.xx.xx.xx
port: xxxx
connectMode: DIRECT_PEERING
  1. By default Memorystore provides direct peering.When using the direct peering mode, Memorystore creates a VPC peering between the customer VPC network and the VPC network in the Google managed project. So you could create GCE to access the Memorystore for Redis. Please go to Memorystore networking to have more information.

  2. Set up the authentication on the GCE when necessary

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

Run the demo

  1. Google Cloud does not provide offical Redis driver for CRUD and other data operations. But Google Cloud does provide the official driver for Memorystore management.

  2. In the demo, the standard Node.js driver for Redis is used. The demo gives the basic idea how pubsub functionality works in Memorystore for Redis.

  3. Prepare the node.js enviroment by using nvm, and run the demo as below.

npm install
Change pubsub.js to specify the host and port for the Memorystore for Redis
node app.js
  1. Also, Redis tools provide command line tools for pubsub as well.
redis-cli -h xx.xx.xx.xx -p xxxx
>publish channel:test "hello,test"
>subscribe channel:test
  1. The demo is originally from this github, and is changed for the demo.

About

Redis pub/sub demo in Memorystore

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published