Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of the working principle of Memcached

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the example analysis of Memcached's working principle. The introduction in this article is very detailed and has certain reference value. Interested friends must read it!

Memcached works.

Memcached processes atoms for each (key, value) pair (hereinafter referred to as kv pair), and the key is converted into a hash-key by a hash algorithm for easy lookup, comparison and hash as much as possible. Memcached, meanwhile, uses a secondary hash, maintained by a large hash table.

Memcached consists of two core components: server and client. In a memcached query, the client first determines the server location of the kv pair by calculating the hash value of the key. When the server is determined, the client sends a query request to the corresponding server to find the exact data. Because there is no interaction and no multicast protocol, the impact of memcached interactions on the network is minimized.

For example, consider the following scenario, where there are three clients c1, c2, c3, and three ms s1, s2, s3:

Set kv pair

c1 Want to set key="com",value="iQiyi"

c1 Get the server list, hash the key, and determine the location of the server stored by kv according to the hash value.

S2 was selected.

c1 connects to s2, s2 receives the request and saves (key="com",value="iQiyi")

Get kv pair

c3 wants the value of key="com"

c3 uses the same hash algorithm to calculate the hash value, and determines that the value of key="aa" exists on s2.

c3 connects to s2 and gets value="iQiyi" from s2

Any other requests from c1, c2, c3 for the value key="com" will be sent to s2

The above is all the content of this article "Memcached example analysis of how it works", thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report