Next steps with Redis

Redis is not a replacement for your SQL database, but a fast in-memory storage that is more suitable for certain tasks. Add it to your stack and use it when you really feel it's needed. The following are some scenarios in which Redis suits pretty well:

  • Counting: As you have seen, it is very easy to manage counters with Redis. You can use incr() and incrby() for counting stuff.
  • Storing latest items: You can add items to the start/end of a list using lpush() and rpush(). Remove and return the first/last element using lpop() / rpop(). You can trim the list length using ltrim() to maintain its length.
  • Queues: In addition to push and pop commands, Redis offers blocking queue commands.
  • Caching: Using expire() and expireat() allows you to use Redis as a cache. You can also find third-party Redis cache backends for Django.
  • Pub/sub: Redis provides commands for subscribing/unsubscribing and sending messages to channels.
  • Rankings and leaderboards: Redis sorted sets with scores make it very easy to create leaderboards.
  • Real-time tracking: Redis's fast I/O makes it perfect for real-time scenarios.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.156.202