REmote DIctionary Server (REDIS) is an open source, in-memory data structure store which was created by Salvatore Sanfilippo in 2009 for real-time web analytics. This open source project had been sponsored by VMware and Pivotal Software, and since June 2015, has been sponsored by Redis Labs. According to Redis Day TLV 2016, Redis has gained lots of adoption in thousands of companies including American Express, Atlassian, Ariba, Facebook, Intuit, TripAdvisor, Twitter, and Verizon.
You can use Redis to cache a user profile, create a leaderboard, track real-time activities on a website, implement a spam filtering system, use it as a message queue, and more. At MuleSoft, we have seen customers use Redis as a cache storage layer while using MongoDB as a persistent message storage layer, to process huge amounts of payroll and employee data with Redis Cluster, and as a NoSQL database. To support the growing number of customers leveraging Redis, we are thrilled to release the Anypoint Connector for Redis today.
Here is a quick example of how to use the Redis Connector, compatible with Redis 2.8, 3.0 and 3.2. This demo app allows you to test basic operations of Redis Connector. The app consists of two flows; the first flow shows 12 different operations which will be triggered by your choice, the second flow shows you a web page where you can pick an operation.
Let’s configure this Redis Connector first. Go to Global Elements, and find “Redis.” After selecting “Redis,” click on “Edit”.
In the Redis: Configuration, you can specify the configuration of your Redis server. You could directly add your Redis Server information in the configuration, but I recommend that you use the properties file to add your configuration information. Since I’m running a Redis Server locally on my Mac, the configuration of my Redis Server I will use looks like this:
After you complete the configuration for your Redis environment, run the app. When you open up a browser and hit localhost:8081, your browser will show the following page.
Since implementing a leaderboard is one of main use cases, I’d like to show an example of using a sorted set. When you scroll down on the webpage, you will see the following page.
I added the following data to a sorted set called “Max the Mule.”
|Max the Mule||Nathan||50|
|Max the Mule||Anton||70|
|Max the Mule||Ashley||110|
|Max the Mule||Alex||150|
I’m only interested in those who scored higher than 100, so when I put the following information in “Get range by score”, Redis will show only Ashley and Alex who scored more than 100.
For new users, try the above example to get started, and for others, please share with us how you are planning to use the Redis Connector! Also, explore the Anypoint Exchange to see other resources you can leverage today.