YugaByte YugaByte
PRODUCT
YugaByte DB Enterprise Edition Compare
SOLUTIONS

Use Cases

Distributed OLTP Apps Fast Data Infrastructure

Deployment Options

Microservices & Containers Multi-Region & Multi-Cloud

Roles

App Development Cloud Operations

Industries

Software-as-a-Service Financial Services Internet of Things E-Commerce
DOCS
Install Explore Develop FAQ
RESOURCES

Meet Us

Events Online Talks

Request Help

GitHub Forum Gitter
ABOUT
Team Careers In the News Contact Us
BLOG
Download

Docs

  • Introduction
    • Overview
    • Core Features
    • Benefits
  • Quick Start
    • 1. Install YugaByte DB
    • 2. Create Local Cluster
    • 3. Test Cassandra API
    • 4. Test Redis API
    • 5. Run Sample Apps
  • Explore
    • 1. Linear Scalability
    • 2. Fault Tolerance
    • 3. ACID Transactions
    • 4. Secondary Indexes
    • 5. Auto Sharding
    • 6. Auto Rebalancing
    • 7. Tunable Reads
  • Develop
    • Client Drivers
      • Java
      • NodeJS
      • Python
    • Learn
      • 1. SQL vs NoSQL
      • 2. Data Modelling
      • 3. ACID Transactions
      • 4. Aggregations
      • 5. Batch Operations
    • Ecosystem Integrations
      • Apache Spark
      • JanusGraph
      • KairosDB
    • Real World Examples
      • E-Commerce App
      • IoT Fleet Management
  • Deploy
    • Private DC
    • Kubernetes
      • Local SSD
    • Public Clouds
      • Amazon Web Services
      • Google Cloud Platform
      • Microsoft Azure
    • Enterprise Edition
      • 1. Initial Setup
      • 2. Install Admin Console
      • 3. Configure Cloud Providers
  • Manage
    • Enterprise Edition
      • Create Universe
      • Edit Universe
      • Edit Config Flags
      • Upgrade Universe
      • Delete Universe
    • Diagnostics Reporting
  • Troubleshoot
    • Troubleshooting Overview
    • Cluster Level Issues
      • Cassandra Connection Issues
      • Redis Connection Issues
    • Node Level Issues
      • Check Processes
      • Inspect Logs
      • System Stats
    • Enterprise Edition
      • Troubleshoot Universes
  • Architecture
    • Basics
      • Single Node
      • Universe, YB-TServer, YB-Master
      • Sharding
      • Replication
      • Persistence
      • Query Layer
      • Acknowledgements
    • Core Functions
      • Universe Creation
      • Table Creation
      • Write IO Path
      • Read IO Path
      • High Availability
    • Transactions
      • Isolation Levels
      • Single Row Transactions
      • Distributed Transactions
      • Transactional IO Path
  • Comparisons
    • Apache Cassandra
    • MongoDB
    • Redis
    • Azure Cosmos DB
    • Google Cloud Spanner
    • Apache HBase
  • API Reference
    • Apache Cassandra
      • ALTER TABLE
      • CREATE INDEX
      • CREATE KEYSPACE
      • CREATE TABLE
      • CREATE TYPE
      • DROP KEYSPACE
      • DROP TABLE
      • DROP TYPE
      • USE
      • INSERT
      • SELECT
      • UPDATE
      • DELETE
      • TRANSACTION
      • TRUNCATE
      • Simple Value
      • Subscript
      • Function Call
      • Operator Call
      • BLOB
      • BOOLEAN
      • MAP
      • FROZEN
      • INET
      • Integer
      • Non-integer
      • TEXT
      • Date & Time
      • UUID & TIMEUUID
    • Redis
      • APPEND
      • AUTH
      • CONFIG
      • DEL
      • ECHO
      • EXISTS
      • FLUSHALL
      • FLUSHDB
      • GET
      • GETRANGE
      • GETSET
      • HDEL
      • HEXISTS
      • HGET
      • HGETALL
      • HKEYS
      • HLEN
      • HMGET
      • HMSET
      • HSET
      • HSTRLEN
      • HVALS
      • INCR
      • MGET
      • MSET
      • ROLE
      • SADD
      • SCARD
      • SET
      • SETRANGE
      • SISMEMBER
      • SMEMBERS
      • SREM
      • STRLEN
      • TSADD
      • TSGET
      • TSRANGEBYTIME
      • TSREM
      • TSCARD
      • TSLASTN
      • ZADD
      • ZCARD
      • ZRANGEBYSCORE
      • ZREM
      • ZREVRANGE
  • Admin Reference
    • yb-ctl
    • yb-docker-ctl
    • docker-compose
    • yb-master
    • yb-tserver
  • FAQs
    • Product
    • Architecture
    • Enterprise Edition
    • Cassandra API
Quick Start

Test YugaByte DB Redis API

    • 1. Connect with redis-cli
    • 2. Simple key-value types
    • 3. Hash data types

After creating a local cluster, follow the instructions below to test YugaByte DB’s Redis API.

redis-cli is a command line interface to interact with a Redis server. For ease of use, YugaByte DB ships with the 4.0.1 version of redis-cli in its bin directory.

1. Connect with redis-cli

  • Docker
  • Kubernetes
  • macOS
  • Linux
  • Run redis-cli to connect to the service.
$ docker exec -it yb-tserver-n3 /home/yugabyte/bin/redis-cli
127.0.0.1:6379> 
  • Run a Redis command to verify it is working.
127.0.0.1:6379> PING
"PONG"
  • Run redis-cli to connect to the service.
$ kubectl exec -it yb-tserver-0 /home/yugabyte/bin/redis-cli
127.0.0.1:6379> 
  • Run a Redis command to verify it is working.
127.0.0.1:6379> PING
"PONG"
  • Initialize YugaByte Redis service.

Setup the redis_keyspace keyspace and the .redis table so that this cluster becomes ready for redis clients. Detailed output for the setup_redis command is available in the yb-ctl Reference.

$ ./bin/yb-ctl setup_redis
  • Run redis-cli to connect to the service.
$ ./bin/redis-cli
127.0.0.1:6379> 
  • Run a Redis command to verify it is working.
127.0.0.1:6379> PING
"PONG"
  • Initialize YugaByte Redis service.

Setup the redis_keyspace keyspace and the .redis table so that this cluster becomes ready for redis clients. Detailed output for the setup_redis command is available in the yb-ctl Reference.

$ ./bin/yb-ctl setup_redis
  • Run redis-cli to connect to the service.
$ ./bin/redis-cli
127.0.0.1:6379> 
  • Run a Redis command to verify it is working.
127.0.0.1:6379> PING
"PONG"

2. Simple key-value types

Insert a key and a value.

127.0.0.1:6379> set mykey somevalue
OK

Query the value by the key.

127.0.0.1:6379> get mykey
"somevalue"

Check if the key exists.

127.0.0.1:6379> exists mykey
(integer) 1

If the value is a number, it can be incremented.

127.0.0.1:6379> set counter 100
OK
127.0.0.1:6379> incr counter
(integer) 101
127.0.0.1:6379> incr counter
(integer) 102
127.0.0.1:6379> get counter
"102"

3. Hash data types

You can create a Redis Hash data type as follows. This models the data for user id 1000 with the following attributes {username : john, birthyear : 1977, verified : 1}.

127.0.0.1:6379> hmset user:1000 username john birthyear 1977 verified 1
OK

You can retrieve specific attributes for user id 1000 as follows.

127.0.0.1:6379> hget user:1000 username
"john"
127.0.0.1:6379> hget user:1000 birthyear
"1977"

You can fetch multiple attributes with a single command as follows.

127.0.0.1:6379> hmget user:1000 username birthyear no-such-field
1) "john"
2) "1977"
3) (nil)

You can fetch all attributes by using the hgetall command.

127.0.0.1:6379> hgetall user:1000
1) "birthyear"
2) "1977"
3) "username"
4) "john"
5) "verified"
6) "1"
Test YugaByte DB Cassandra API
Run Sample Apps
YugaByte

SUBSCRIBE TO NEWS

The latest news, tips, blog posts, and resources.

Copyright © 2017-2018 YugaByte, Inc. All rights reserved.

Apache and Apache Cassandra are trademarks of the Apache Software Foundation in the United States and/or other countries. Redis and the Redis logo are the trademarks of Salvatore Sanfilippo in the United States and other countries. No endorsement by these organizations is implied by the use of these marks.