How to flush the Redis cache while using the AWS Elasticache cluster? With our AWS Support Services, Bobcares offers a simple solution to this query.
Flush Redis Cache While Using AWS
Redis is a data structure store that can be used for the purpose of caching. It is open-source and supports data structures like strings, hashes, lists, sets, etc. Redis is a popular distributed caching engine because it is highly available and tuned for speed.
We can flush the cache and delete all keys using any one of the following commands:
FLUSHDB
FLUSHALL
The FLUSHDB
command removes all the keys of the currently selected DB. And the FLUSHALL
command deletes all the keys of all the existing databases, not just the currently selected one.
Syntax For Flushing Redis Cache
The syntax for flushing the Redis cache from the shell prompt is as follows:
redis-cli FLUSHDB redis-cli -n DB_NUMBER FLUSHDB redis-cli -n DB_NUMBER FLUSHDB ASYNC redis-cli FLUSHALL redis-cli FLUSHALL ASYNC
We can also configure the server’s hostname, port, socket, and password when connecting to the server as given below. We can use the REDISCLI_AUTH
environment variable to pass this password more safely.
redis-cli -h {hostname_IP} -p {port} -s {socket} -a {password} FLUSHDB redis-cli -h {hostname_IP} -p {port} -s {socket} -a {password} FLUSHALL
How To Flush Redis Cache While Using AWS Elasticache Cluster?
Amazon ElastiCache is an Amazon Web Services completely managed in-memory data storage and cache service.
We must run the FLUSHDB or FLUSHALL command on each master node when utilizing a cluster. For example, using bash for loop, execute the following command on three master nodes:
# three master node ip address for s in 10.105.29.1 10.105.29.2 10.105.29.3 do echo "Flushing DB from $s node ..." redis-cli -h $s FLUSHDB done
No need to reboot the node. We can run the above commands from the EC2 cloud server/host. Or else, we can use API:
# FLUSH everything # $ redis-cli -h AWS-Elasticache-Host -p AWS-Port_Number FLUSHALL # FLUSH by DB_NUMBER aka specific DB # $ redis-cli -h AWS-Elasticache-Host -p AWS-Port_Number -n DB_NUMBER FLUSHDB
[Searching for a solution to a different query? We are just a click away.]
Conclusion
To conclude, the article provides a brief description of the Redis Cache and how to flush it when using the AWS Elasticache cluster.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments