How to use the Redis command-line tool with Azure Cache for Redis in windows Machine

How to use the Redis command-line tool with Azure Cache for Redis in windows Machine

Azure-Redis-cache-connection-through-azur redis cli

Use the Redis command-line tool with Azure Cache for Redis in windows

Once you installed the redis cli (it is by default installed in C:\Program Files\Redis) .Before connecting to the azure redis cache you need 3 parameters those are 
  1. Azure redis cache hostname
  2. Azure redics cache port  6379(without ssl) 6380 with ssl access
  3. Azure redis cache access keys
To Get the Azure Redis properties follow the below screenshots
Azure-redis-cahce-Host-information

Azure-redis-access-keys
Once you get the 3 properties just go to the installation directly of redis cli and type the below command.

redis-cli.exe -h Your hostname -p 6379 -a you access key
Once it is done you are connected to cloud azure redis cache.

Most used commands in redis cli 

DEL key : This command deletes the key, if it exists.
DEL KEY_NAME 

DUMP key : This command returns a serialized version of the value stored at the specified key.
DUMP KEY_NAME

EXISTS key : This command checks whether the key exists or not.
EXISTS KEY_NAME

EXPIRE key seconds : Sets the expiry of the key after the specified time.
Expire KEY_NAME TIME_IN_SECONDS

EXPIREAT key timestamp : Sets the expiry of the key after the specified time. Here time is in Unix timestamp format.
Expireat KEY_NAME TIME_IN_UNIX_TIMESTAMP 

PEXPIRE key milliseconds : Set the expiry of key in milliseconds.
PEXPIRE KEY_NAME TIME_IN_MILLISECONDS

PEXPIREAT key milliseconds-timestamp : Sets the expiry of the key in Unix timestamp specified as milliseconds.
PEXPIREAT KEY_NAME TIME_IN_MILLISECONDS_IN_UNIX_TIMESTAMP

KEYS pattern : Finds all keys matching the specified pattern.
KEYS PATTERN

MOVE key db : Moves a key to another database.
MOVE KEY_NAME DESTINATION_DATABASE 

PERSIST key : Removes the expiration from the key.
SET Name redis 

PTTL key : Gets the remaining time in keys expiry in milliseconds.
SET Nmae redis

TTL key : Gets the remaining time in keys expiry.
TTL KEY_NAME

RANDOMKEY : Returns a random key from Redis.
RANDOMKEY 

RENAME key newkey : Changes the key name.
RENAME OLD_KEY_NAME NEW_KEY_NAME

RENAMENX key newkey : Renames the key, if a new key doesn't exist.
RENAMENX OLD_KEY_NAME NEW_KEY_NAME

TYPE key : Returns the data type of the value stored in the key.
TYPE KEY_NAME 

SUBSCRIBE TO OUR NEWSLETTER

I’m the Founder of quickdevops.com. I am a Professional Blogger, Application developer, YouTuber. I’ve been blogging since 2015.I spend a lot of time learning new techniques and actively help other people learn web development through a variety of help groups and writing web development tutorials for my website and blog about advancements in web design and development.Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie or planning a trip to someplace I've never been before.

2 Responses to "How to use the Redis command-line tool with Azure Cache for Redis in windows Machine"