GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-docs-samples/bigtable/memorystore at main · bhoogter/java-docs-samples

Expand file tree

/

memorystore

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

memorystore

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
src
src
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

README.md

Outline

Google Cloud Bigtable Memorystore

This code shows how to use Cloud Bigtable with a caching solution hosted on Memorystore.

Setup

  1. Create a Bigtable instance

  2. Set your variables

    BIGTABLE_PROJECT=YOUR-PROJECT-ID OR $GOOGLE_CLOUD_PROJECT
    INSTANCE_ID=YOUR-INSTANCE-ID
    TABLE_ID=mobile-time-series # Example table for sample  
    
  3. Create a table with one row

    echo project = $BIGTABLE_PROJECT > ~/.cbtrc
    echo instance = $INSTANCE_ID >> ~/.cbtrc
    
    cbt createtable $TABLE_ID "families=stats_summary" 
    cbt set mobile-time-series phone#4c410523#20190501 stats_summary:os_build=PQ2A.190405.003 stats_summary:os_name=android
    

Memcached

  1. Set up a Memcached instance locally or hosted on Memorystore.

  2. Get the Memcached host IP and set that as a variable.

    MEMCACHED_DISCOVERY_ENDPOINT="0.0.0.0"
    
  3. Run the code. If you are trying to connect to Memcached on Memorystore, you will need to run this code within the same VPC network to connect. The easiest way to do this is by creating a Compute VM on the same network, SSHing to that and running the code from there.

    mvn compile exec:java -Dexec.mainClass=Memcached \
    -DbigtableProjectId=$PROJECT_ID \
    -DbigtableInstanceId=$INSTANCE_ID \
    -DbigtableTableId=$TABLE_ID \
    -DmemcachedDiscoveryEndpoint=$MEMCACHED_DISCOVERY_ENDPOINT
    

    The first time you run the program, it will fetch the data from Bigtable. If you run it again (within the cache limit), it will fetch the data from Memcached.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.