Author: Manish Prabhu
What is redis?
Redis is an open source key value store. It uses memory to store its database for most of the time. It is fast because it stores data in memory instead of disk. It can be used in web applications for holding user data.
Setup redis in windows 7:
Step 1:Download windows compatible redis from official github (https://github.com/dmajkic/redis/downloads) location.
Step 2:Extract the folder to a location that you want.
Step 3:Open a folder 64 bit or 32 bit according to your operating system.
Step 4:Run redis-server.exe file.
Step 5:Run redis-cli.exe file to open a command prompt for redis.
Step 6:Once you connect to localhost with 6379 port the status will change on another window showing 1 client connected.
Redis connector in mule 4:
You can connect redis storage with mulesoft using Redis connector in mule 4. This connector is not present in pallet by default. Hence you need to import it from exchange.
You can perform various operations in redis using this connector.
Operations in redis connector:
This connector is used to assign a value to a key. You should specify both key and a value while using this connector. Hence you should configure set connector like:
You can verify the output by making a request through a postman collection.
This operation is used to get a value for a specified key. The connector configuration should be:
You can verify the output of this operation by making a request through postman.
This operation is used to check whether a key exists in memory(storage) or not. You should specify a name of key to check whether it exists or not. The connector configuration should be:
You can verify the output in postman. The output will be true if the key exists, otherwise it will be false.
This connector is used to delete a key from storage. You will get 1(digit) in output. The connector configuration will be:
You can verify the output in postman.
If you want to check whether a key is actually deleted by making a request. You will get null in the output.