DEV Community

Cover image for NoSQL Databases and My Adventure with Redis
Jacob Henning
Jacob Henning

Posted on • Originally published at jacobhenning.com

NoSQL Databases and My Adventure with Redis

Last year I built a Laravel app with Redis as the primary database. It was for a hackathon, the goal was to use Redis as much as possible, and I practically used Redis for everything. Cache, Queue, Event System, and the primary database. The only thing I didn’t use it for was error logging.

For my fellow Laravel developers, you might be wondering (or already know) how I used a NoSQL database alongside the Laravel framework (even though it’s built to use MySQL.) It was super easy due to the awesome way Laravel is set up. I updated two classes. One is for providing the user to the framework. The other is for accessing key fields for authorization to the framework. All I had to do was design how we get the user from Redis (rather easy). Everything else slid right into place.

Using Redis as your primary database is pretty awesome. You can add any field you want to the user at any time. No migrations. It’s very fast. The way I set it up, I was able to access the user via token, email, and id. But any key can be set up for our user. You don’t have to set up relationships but you can if you would like to. I ended up having a lot of fun with this project.

I use Redis in all my projects… But I’ve never used it as the primary database since this hackathon challenge.

But why not?

I told you Redis was fast, fun, and easy to set up. Why wouldn’t I keep using it as my primary database? Because it cannot do what I want my database to do in the long run. Since when did queries become a hassle instead of a feature? I like being able to query large amounts of data and produce specific metrics quickly. I like to know what my data model is going to look like when I’m accessing it. Using MySQL lets me request data in a structured way and then cache it using Redis. I guess what I’m trying to say is that I think MySQL is easier to use than NoSQL so long as you know how to use it.

I can only speak from my experience as a developer. Maybe I’m not using NoSQL databases correctly and there is a far better process I could implement. Please let me know. I’m open-minded on the subject and would love to hear from people who use NoSQL databases and scale them up. I’ve never seen this happen before and would love to learn what NoSQL databases can do.

Top comments (0)