This is a blog series on using the Redis NoSQL database.
Introduction
I have been around databases for 30 years starting out with IDMS on ICL mainframes. That progressed into Sybase and Microsoft SQL Server. I have cut my teeth on relational databases however; the one size fits all no longer applies anymore. Those previous eras can be referred to as the first and second database revolution targeting Mainframes, client/server and the beginnings of the web.
The third database revolution are NoSQL databases. With the growth of the cloud, social media, big data, mobile and IOT, a new wave of technologies needed to be designed to cope with the different demands placed on it.
NoSQL databases can be categorized as follows:
- Document Orientated
- Key Value Store
- Wide Column
- Graph
In order to talk about NoSQL it is often easier when comparing it against a relational database. This is by no means the complete list, just some of the common ones.
SQL |
NoSQL |
Predefined schema |
No schema enforcement (All Data has a schema) |
Tabular |
Various data structures |
ACID compliance |
BASE compliance. |
Scales vertically |
Scales horizontally |
Full transaction support |
Partial transaction support |
SQL Query language |
SQL like language or custom language |
There are other NoSQL types but these are the most popular. If you look at the website DB-Engines Ranking it shows a list of all the databases based on data extracted from search engines. It uses the data to determine how often a search on a particular engine is performed and thereby accessing how popular it is. At the time of writing the most popular Key Value database is Redis.
Redis (Remote Dictionary Server)
What exactly is a Key Value Store? It means all access to the database is done by referencing a key. What is then returned is one or more values however; values are not just simple strings, more like data structures. As we shall see in another blog, there are a number of different types we can use for values which makes it very powerful. Redis focuses on performance and simplicity. The following table gives a list of the features of Redis.
Platform |
|
Version |
|
Data Durability |
|
Indexes |
|
Query Language |
|
Compelling Features |
|
When would you use Redis
This is probably the most important question when determining a specific database platform. Redis is typically used in the following scenarios:
Session Storage
Create an HTTP session store which lowers your page load times without compromising stability.
Caches
Cache data retrieved from applications like twitter which can then have expirations set.
Message Queues
Can act as a Service Broker for publishers and consumers.
Notifications
Allows clients to subscribe to Pub/Sub channels in order to receive events affecting the Redis data set in some way.
Leader boards
Keeping live information in sorted sets.
Installing Redis
Redis requires Linux or MacOS. These can be downloaded from here.
If you are a windows shop you have a number of options:
- Run Redis in a Linux container using docker running in Linux mode. In fact at the time of writing, Docker have an experimental release that allows you to run Linux containers whilst running in Windows mode.
- Microsoft Azure has a number of Redis installations.
- If you sign up with Redis Labs you can get a free cloud Redis installation to try out.
In the next blog I will go into some basics.