- 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.
- 自己動手寫分布式搜索引擎
- Photoshop CC實戰從入門到精通
- Photoshop CS6完全自學案例教程(微課版)
- Unity Game Development Essentials
- 零基礎學后期:Photoshop+Lightroom數碼照片處理從新手到高手
- BIRT 2.6 Data Analysis and Reporting
- NHibernate 3.0 Cookbook
- 量化投資與FOF投資:以MATLAB+Python為工具
- 正則表達式必知必會(修訂版)
- Photoshop移動UI設計從入門到精通
- UG NX 12.0中文版從入門到精通
- 金融精英PPT實操手冊:世界知名公司這樣展示研究報告
- 攝影師的后期必修課(RAW格式篇)
- 卷珠簾:Photoshop古風插畫技法完全教程
- Building SOA/Based Composite Applications Using NetBeans IDE 6