Teknikal_Domain's Personal Blog

#<ENT:NTA:NnT:SSrgS:H66-198:W200:CBWg>

My Quick Peek Into Redis

2020-03-16 2 min read Programming Software Teknikal_Domain

Yeah, it’s definitely been somthing of a journey, alright. Redis , for those unaware, is, essentially an in-memory key-value store. At the most pasic level, this seems fine. Start looking into the documentation, and.. well it just seems to do everything really.

Redis Data Types

While at the most underlying level is is just a key-value store, this is presented as a few different forms that can be used:

  • Just normal strings (set “this key” to “this value”)
  • Lists: strings, sorted by insertion order (linked list)
  • Set: strings, unique, and unsorted
  • Sorted set: Sets, where each key has a floating point “score” that’s sorted on
  • Hash: Hash map table from a key string to a value string.. so one “hash” key in redis can have multiple other keys in itself
  • Bitmaps: there are commands that can use a string as a bit array
  • HyperLogLog: probabilistic data structure for estimating set cardinality
  • Stream: an entire time-based stream of individual messages, Kafka style

That is a lot of functionality for a “key-value” store. But wait there’s more!

Redis as a Message Broker

through use of the literal PUBLISH and SUBSCIBE commands, redis can turn into an MQTT-like broker for fire-and-forget messages

Redis as a Cache

Not only can individual keys be given a TTL (time-to-live) value, after which they’re deleted, redis can be configured on startup for evicting keys in a LRU (Least Recently Used), or LFU (Least Frequently Used) fashion.

Redis using plain string keys, configured to LRU expire all keys means it’s basically just… Memcached.

Potential Uses?

I cannot give a comprehensive list, that’s a lot of functionality to pack into something with such an easy to understand API, and lightweight memory footprint (no, I’m not sponsored, it’s just really cool.)

Given it’s just.. flexibility, I can use one program to act as my configuration database, IPC system, log, temporary result cache, and processing queue, it’s… well, it definitely has made itself useful.

Usually, I don’t software with a rather broad set of uses, they tend to spread themselves a little “too thin”, yes they can do everything, but not necessarily as well as something dedicated. Redis though… well heck, if you’re already using it for something there’s almost no reason not to add something else, since it’s already there and won’t add much more overhead to what you’re already doing with the thing anyways.

More Explanations?

I’ll definitely go into detail about some features of Redis soon, but this is meant to be an overview, not tutorial. Stay tuned, more is coming soon.

comments powered by Disqus