In Matthew Barker’s Getting started with Redis post, we covered the 5 data structures in Redis. This overview will cover some key operations and common uses, along with security options and a few simple example scripts.
EXISTS (boolean response)
So while there are some examples of the SMEMBERS command for search, below is an example using SSCAN which is a “cursor based iterator” rather than full out locking command.
Searching for a thing
While some use cases are more common than others, keep in mind that Redis doesn't have to work alone. You can choose to leverage its speed and flexibility in conjunction with other technologies to help build bridges and even new platforms, as well as to streamline communications between services using Redis.
Common use cases:
- caching (most types)
- session stores
While Redis is designed to be accessed by trusted clients, you can, however, implement security from multiple levels:
- implement security around the application
- SSL encrypt the pipeline your passing Redis from/to client<->server
- set requirepass in redis.conf or config set
- rename the config operation so that it's not available
Depending on the needs of your application, you can choose to leverage all of these elements together, or on an individual basis.
One extremely useful script that I have used in several applications is redis-simple-cache.
I recommend this code because of its simplicity, ease-of-use and consistent performance, if you choose not to use the de-facto Werkzeug implementation.
And thats it… awesome, right?
While predis is widely seen as the Redis driver of choice, in my experience, it can occasionally have some scalability issues when streaming at high volumes. In this case, I’d recommend taking the time to install the C-based driver phpredis if you have the option.
Many other great options are generously provided on Redis.io.
There are many useful real-world examples of Redis being used to improve system intercommunication and to build platform scalability. However, as the technology continues to evolve, it’s important to keep a pulse on how its capabilities can benefit your business.