- Mastering Redis
- Jeremy Nelson
- 438字
- 2021-04-02 20:37:55
Popular usage patterns
A very popular use pattern for Redis is as an in-memory cache for web applications. Redis is available as a caching option for popular web frameworks such as Django, Ruby-on-Rails, Node.js, and Flask. As a popular caching technology Redis excels in web applications for storing new data while evicting stale data. For web applications, the cached data can range from single HTML character strings, widgets, and elements to entire web pages and websites.

By utilizing Redis's ability to set an expiration time on a key, one of Redis' popular caching strategies called Less Recently Used (LRU) is robust enough to handle even the largest web properties, with the most popular content remaining in cache but stale and little-used data being evicted from the data store. This caching use case doesn't assume that the original web element or page is generated from the data in Redis; most likely, the web content was dynamically generated from other sources of data with Redis, in this use pattern, and operates as an excellent web caching layer in this setup.
The second popular use pattern for Redis is for the metric storage of such quantitative data such as web page usage and user behavior on gamer leaderboards. Using bit operations on strings, Redis very efficiently stores binary information on a particular characteristic. Usage for a website could be stored with a key constructed from a date such as page-usage:2016-11-01
, which has a string attached with a bit flipped to 1 the first time a web page is accessed by a user.

The daily usage for the website for November 1 can be obtained through a simple BITCOUNT
Redis command on the page-usage:2016-11-01
key. In a 2011 blog post, individuals at a start-up named Spool
explain in detail how they use bitmaps and Redis bit operations to store the user activity on their website with this design pattern.
The third popular Redis use pattern is as communication layer between different systems through a publish/subscribe (pub/sub for short) model, where one can post messages to one or more channels that can be acted upon by other systems that have subscribed to or are listening to that channel for incoming messages.

Typically, publishers do not need to know the specific subscribers to send messages to them (say in a point-to-point messaging model); only the message contents and what channel to send the message should be known. Similarly, a subscriber does not need to know individual publishers, only the channel to receive messages. The pub/sub pattern is nice because it scales easily, and the publishers and subscribers can be very different programs and systems.
- 3ds Max 2016中文版完全自學(xué)手冊
- Excel 2013電子表格處理
- Cinema 4D 2024+AI工具詳解與實戰(zhàn)(視頻微課·全彩版)
- Photoshop網(wǎng)店圖片處理實訓(xùn)教程
- 中文版Photoshop CS6從新手到高手(超值版)
- 數(shù)碼攝影后期密碼Photoshop CC調(diào)色秘籍(第2版)
- 零基礎(chǔ)學(xué)Premiere Pro短視頻制作
- 3ds Max-Photoshop游戲模型制作全攻略
- jQuery UI 1.6: The User Interface Library for jQuery
- 中文版3ds Max 2014/VRay 效果圖制作實例教程(全彩超值版)
- 中文版SketchUp/Artlantis印象渲染技術(shù)精粹
- 設(shè)計+制作+印刷+商業(yè)模版Photoshop+InDesign實例教程
- 精通Microsoft 365云計算管理:SharePoint Online篇
- 絕了!Excel可以這樣用:Excel函數(shù)范例實戰(zhàn)精粹(速查版)
- Oracle Application Express 4.0 with Ext JS