Now for me, when I want to learn something new, I like to get into the lowest possible level of the concept that I feel is necessary for me to understand. I could have just jumped into redis using the gem already built for ruby, but to me, that’s a layer too high to start on. Though I don’t think I need to understand how redis was built, I feel I should understand how to use redis in a basic level before dropping my ruby language on top of it. Fortunately for me, I did find a few useful ways to get started on that.
Trying Out Redis
The first thing I found, worked with, in my attempts to learn redis was an interactive demonstration that will run you some of the basic ideas and functionalities of redis. Many languages have similar ideas out there on the web, and I’ve done a few in the past. Though they don’t to a lot of teaching (I wouldn’t really call them tutorials), I do find they help me just get familiar with some of the syntax of the language. Primarily what you do in something like this is you get told to type something on on the screen, you type it, and then you see what happens, and then you are told to type something else.
To refresh my thoughts on it, I just did the tutorial again, while writing this article. I’d say for a first timer, it would probably take about 10-15 minutes to get through (depending on how much you want to experiment with the commands given versus just typing them out yourself). The interactive code provides a small introduction to some of the more basic redis data types, (it doesn’t touch on geo or hyperloglog for instance) and some of the more commonly used commands of each type. To me, things like this are a good, gentle, introduction to something that maybe you thought would be overwhelming to learn in the beginning (like I did with redis). For instance this here is a list of all the available redis commands. I doubt this interactive introduction touches on 10% of the commands on that page, but I feel it does achieve its intended job of a quick demonstration of the power of what redis can do with some pretty simple commands.
Diving Deeper into Data Types
After that quick introduction to some simple redis commands and functionality, the next thing I wanted to do was to learn more about the the various data types (both introduced and not) that reids has to offer. A little exploring of the same base web site that the interactive introduction was on led me to this page which covers exactly what I was looking for. Each section delves a bit deeper into the topics and concepts I had previously been introduced to, while at the same time broaching more topics, and data types, while still not covering the entire list I linked to previously.
However, it was a good next step. I learned a bit more about redis and its data types, and my mind got going on possible ways to use redis in a variety of ways and projects. I always like it when something I feel I should learn also opens up new ideas and pathways to things I want to do. It makes it easier to learn the new things when it’s clear that they can help you right away with something you’ve been trying to do for a while, or at least I find it that way.
Using Redis in Your Environment
Much like ruby, you can run redis on your own environment, either just to experiment with the tutorials above at your leisure or to use it within applications you’re building to see how it works. (Integrating it into said applications is another story for another time). The redis home page provides good instruction on how to get redis started on your machine. Though it’s not explicitly spelled out on this page, yes Mac users (like me) you can use homebrew instead to install redis. There’s really only a few key commands I feel are important to know to get started at least:
redis-server- does what it sounds like it’ll do. It starts the redis server on your local machine. - will launch the server at the default factory settings which is all you really need to start.
redis-cli- launches your command line interface, searching at those same default settings, so you can practice any of the commands you learned in the sections above.
FLUSHDB- To my understanding, if you don’t expire something, or remove it, redis might store what you’ve entered into it for a while as it is a memory store. This command used with redis-cli will clear out your redis database. I realize there are modifiers to use if you have multiple databases, but as a beginner, it’s a good thing to practice with one database and flush it periodically so it doesn’t confuse your studies.
SHUTDOWN- used with redis-cli this command will shutdown your redis server. Shutting down the terminal window in which you started it does not shut down the server. I found shutting it down just avoids confusion or problems later on. I do my best to remember to shut it down after every time I’m done using it for the time being.
And, well, that’s it. This was just about getting my feet a bit more wet with redis and becoming comfortable with ideas and concepts. There’s more down the road obviously, but that will come later I’m sure, and hopefully will include building that application I mentioned earlier which seems more and more viable through use of redis.