Heroku is a popular PaaS offering that allows software developers to easily deploy their code without worrying about the underlying infrastructure. By using a simple 'git push heroku' command, developers are able to deploy their application flawlessly. This platform offers support for a wide range of programming languages such as Java, Ruby, PHP, Node.js, Python, Scala, and Clojure.
Here's a quickstart guide to deploy Ruby apps on Heroku using Redis. We will be deploying a sample Leaderboard app and will be using company valuation and stock tickers as its domain.
Create your free Redis Enterprise Cloud account by visiting this link.
Follow this link to create a Redis Enterprise Cloud subscription and database as shown below:
The database endpoint URL is unique so will be different in your case. Save it for future reference.
If you are using Heroku for the first time, create your new Heroku account through this link.
For this demonstration, we will be using a Sample Redis Leaderboard app.
Run the commands below to get a functioning Git repository that contains a simple application as well as a
Go to the Heroku dashboard, click "Settings" and set
REDIS_PASSWORD under the Config Vars.
Refer to Step 1 for the correct values to use.
You now have a functioning Git repository that contains a simple application as well as a
app.json file, which is used by Node’s dependency manager.
Wait for few seconds and you will see the messages below:
Open https://thawing-shore-07338.herokuapp.com/ to access your application on the browser. Please note that the Web URL is unique, hence it will be different in your case.
The AAPL's details - market cap of 2.6 triillions and USA origin - are stored in a Redis hash like this:HSET "company:AAPL" symbol "AAPL" market_cap "2600000000000" country USA
The market capitalization for each company is also stored in a ZSET (Redis Sorted Set).ZADD companyLeaderboard 2600000000000 company:AAPL
Top 10 companies:ZREVRANGE companyLeaderboard 0 9 WITHSCORES
All companies:ZREVRANGE companyLeaderboard 0 -1 WITHSCORES
Bottom 10 companies:ZRANGE companyLeaderboard 0 9 WITHSCORES
Between rank 10 and 15:ZREVRANGE companyLeaderboard 9 14 WITHSCORES
Show rank for AAPL, FB and TSLA:ZREVRANGE companyLeaderBoard company:AAPL company:FB company:TSLA
Add 1 billion to the market cap of the FB company:ZINCRBY companyLeaderBoard 1000000000 "company:FB"
Reduce the market cap of the FB company by 1 billion:ZINCRBY companyLeaderBoard -1000000000 "company:FB"
How many companies have a market cap between 500 billion and 1 trillion?:ZCOUNT companyLeaderBoard 500000000000 1000000000000
How many companies have a market cap over a Trillion?:ZCOUNT companyLeaderBoard 1000000000000 +inf