什么时候需要打破伤风针| 霸凌是什么意思| 红蜘蛛用什么药| lp0是什么意思| 黄体酮低吃什么补得快| 深千尺是什么意思| 肾挂什么科| 专长是什么意思| 飞蚊症是什么引起的| 为什么射精是流出来的| 嘴巴发麻是什么原因| 务实什么意思| 工薪阶层是什么意思| 花重锦官城的重是什么意思| 1.4是什么星座| 摩羯男和什么星座最配| 每天早上起来口苦是什么原因| 慢性胆囊炎是什么原因引起的| 元宵节吃什么| 泡菜生花用什么方法可以去掉| 近亲结婚生的孩子会得什么病| 为什么支气管炎咳嗽长期不好| 孕妇拉肚子可以吃什么药| 背道而驰什么意思| 地贫有什么症状| 揩油什么意思| 红曲红是什么东西| 枕头发黄是什么原因| 1009是什么星座| 女人耳鸣是什么前兆| 冥王星是什么星| 流鼻血是什么引起的| 甲状腺结节看什么科| 身体缺钾是什么症状| 6月初三是什么日子| 手指甲有黑色条纹是什么原因| joola是什么牌子| 什么可以去湿气| 红景天是什么| 胸部什么时候停止发育| 什么是消炎药| 黄皮肤适合什么颜色的衣服| 移植后屁多是什么原因| 牙冠是什么样子的图片| 籽骨出现意味着什么| 柳树像什么| 吃什么增强免疫力| pyq是什么| 雏菊的花语是什么| 汝窑开片是什么意思| 1991年属羊是什么命| 桑黄是什么树上长出来的| 品牌pr是什么意思| 丰富是什么意思| 什么声什么气| 左下腹是什么部位| 身上很痒是什么原因| 爱情是什么颜色的| 女人腰疼是什么妇科病| 乳酸脱氢酶高是什么原因| 阴茎进入阴道什么感觉| mlb是什么品牌| aquascutum是什么牌子| 球蛋白的功效与作用是什么| 望尘莫及是什么意思| 爱出者爱返福往者福来什么意思| 藤茶有什么功效| 对方忙线中什么意思| 软肋是什么意思| 消化不良吃什么食物| 丹参与什么搭配最好| 清酒和白酒有什么区别| biw医学上是什么意思| 梦见自己尿血是什么意思| 说话不清楚是什么原因导致的| 高筋面粉适合做什么| 能耐是什么意思| 高血压药什么时候吃最好| 五花八门是什么意思| 牙疼吃什么药管用| 梦见死人复活是什么意思| 男性支原体阳性有什么症状| 成人晚上磨牙是什么原因| 十恶大败是什么意思| 子宫偏大是什么原因| 退役和退伍有什么区别| 不喜欢是什么意思| 截单是什么意思| 红虾是什么虾| 烂漫什么意思| 996什么意思| 双脚麻木是什么病的前兆| 鹤膝风是什么病| 杜松子是什么| 什么是黑色素瘤| 湿疹擦什么药膏好| 那天离开你是什么歌| 微不足道的意思是什么| 肾结石不能吃什么东西| 被老鼠咬了有什么预兆| 小朋友手指脱皮是什么原因| 睡觉中途总醒什么原因| 炙热是什么意思| 液体面包是什么| 支原体感染吃什么药好| 麦粒肿不能吃什么食物| 法国用什么货币| 眩光是什么意思| 公主和郡主有什么区别| 杨花是什么| 诅咒是什么意思| 井泉水命什么意思| 口腔溃疡一直不好是什么原因| 补气血吃什么最好最快| 三叉神经是什么病| 布洛芬有什么作用| 摩羯座什么性格| 鼻炎吃什么药| 4月1日什么星座| 杏和什么不能一起吃| vc是什么药| 双生痣是什么意思| 主动脉弓钙化什么意思| 拉红色的屎是什么原因| 事物指的是什么| 血红蛋白偏低是什么原因| 黄花菜不能和什么一起吃| 围绝经期吃什么药调理| 情面是什么意思| 电子烟有什么危害| 什么是免疫治疗| 尿路感染检查什么项目| 王维是诗什么| 吃什么补锌| 小金人车标是什么车| 想的偏旁是什么| 老赖什么意思| 香油是什么油| 经常手麻是什么原因引起的| 百合什么时候开花| 是什么病| 鹤是什么生肖| 6月1日什么星座| 户主有什么权利| 打喷嚏流清鼻涕是什么感冒| 人为什么会变| 痰饮是什么意思| 喝最烈的酒下一句是什么| 孙子兵法是什么生肖| 血压低吃什么水果最好| 九出十三归指什么生肖| 鹰击长空是什么意思| 菠萝和什么不能一起吃| 喝豆腐脑有什么好处和坏处| 胃热口干口苦口臭吃什么药好| 四季更迭是什么意思| 菠萝和什么不能一起吃| 银子有什么功效与作用| 梦到手机丢了什么预兆| 149是什么意思| 长脸男生适合什么发型| 太瘦的人吃什么能长胖| 悠悠是什么意思| 什么的杜鹃花| 蓝脸的窦尔敦盗御马是什么歌| 月子里可以吃什么蔬菜| 网黄是什么意思| 1948年中国发生了什么| 外阴瘙痒涂什么药膏| wba是什么意思| 举世无双是什么意思| 双侧上颌窦炎是什么病| 什么叫肝功能不全| 倒霉是什么意思| 痛风买什么药| parker是什么牌子| 超导体是什么| 夏枯草是什么样子| 婚姻是爱情的坟墓是什么意思| 蚂蚁上树是什么菜| 玟是什么意思| 百折不挠指什么生肖| 提拉米苏是什么东西| iphone的i是什么意思| 肌张力是什么意思| 梦见自己骑马是什么意思| 什么鸡适合炖汤| 喉咙有异物感是什么原因| 公历年份是什么意思| 儿童感冒吃什么药| 骨结核吃什么药效果好| 清什么什么月| sk是什么意思| 气压是什么| 腋下大量出汗是什么原因| 银行卡销户是什么意思| 婴儿黄疸母亲忌口什么| 山珍海味是什么意思| 大黄和芒硝混合外敷有什么作用| 什么仗人势| moncler是什么牌子| 千张是什么| 一什么柳树| 黄精是什么药材| 手指起水泡是什么原因| 什么是脑梗塞| uv是什么材质| 前列腺液和精液有什么区别| 下套什么意思| 梦见老虎是什么预兆| 生蚝不能和什么一起吃| 渣男最怕什么样的女人| 女同是什么| 气管炎不能吃什么食物| 八卦分别代表什么| 贝的偏旁有什么字| 列文虎克发现了什么| 凝胶是什么东西| 眼睛胀是什么原因| 什么鱼最好养不容易死| 什么是关税| 炖牛肉放什么佐料| 微针是什么美容项目| 有尿意但是尿不出来是什么原因| 去肝火喝什么茶| wht什么颜色| 宫是什么意思| 女人吃什么最好| 吃什么补阳气最快| 为什么来月经会拉肚子| 0m是什么意思| 增加骨密度吃什么药| autumn什么意思| 王维是什么派诗人| 干旱是什么意思| 樟脑丸是干什么的| 立夏吃什么食物| 怀孕前三个月需要注意什么| 程门立雪是什么意思| 霰粒肿用什么药| 狼牙套是什么| add是什么意思| 口苦口干吃什么药最好| 柠檬泡水喝有什么好处| 吃什么水果美白| 女性支原体阳性是什么意思| 低蛋白血症是什么病| 5.6是什么星座| 孕妇过敏可以用什么药| 睡觉咬舌头是什么原因| 梦见家里办丧事是什么预兆| 小叶增生是什么症状| 非诚勿扰什么意思| 梦见自己升职了是什么预兆| 肌肉疼痛挂什么科| 果脯是什么| 佞臣是什么意思| 严重失眠挂什么科| 什么植物有毒| 小阴唇是什么| 什么的动作| 膈应是什么意思| 井代表什么生肖| 肌酐低是什么意思啊| 百度

国防军工:关注朝鲜半岛局势 关注混改等相关主题

百度 可以说,有水就有生路、有水就有活路、有水就有了一切。

Memcached (pronounced variously /m?mk???di?/ mem-cash-dee or /?m?mk??t/ mem-cashed) is a general-purpose distributed memory-caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. Memcached is free and open-source software, licensed under the Revised BSD license.[2] Memcached runs on Unix-like operating systems (Linux and macOS) and on Microsoft Windows. It depends on the libevent library.

Memcached
Developer(s)Dormando
Initial releaseMay?22,?2003?(2025-08-14)
Stable release
1.6.38[1]?Edit this on Wikidata / 19 March 2025; 4 months ago?(19 March 2025)
Repository
Written inC
Operating systemCross-platform
Typedistributed memory caching system
LicenseRevised BSD license[2]
Websitememcached.org?Edit this on Wikidata

Memcached's APIs provide a large hash table distributed across multiple machines. When the table is full, subsequent inserts cause older data to be purged in least recently used (LRU) order.[3][4] Applications using Memcached typically layer requests and additions into RAM before falling back on a slower backing store, such as a database.

Memcached has no internal mechanism to track misses which may happen. However, some third party utilities provide this functionality.

Memcached was first developed by Brad Fitzpatrick for his website LiveJournal, on May 22, 2003.[5][6] It was originally written in Perl, then later rewritten in C by Anatoly Vorobey, then employed by LiveJournal.[7] Memcached is now used by many other systems, including YouTube,[8] Reddit,[9] Facebook,[10][11] Pinterest,[12][13] Twitter,[14] Wikipedia,[15] and Method Studios.[16] Google App Engine, Google Cloud Platform, Microsoft Azure, IBM Bluemix and Amazon Web Services also offer a Memcached service through an API.[17][18][19][20]

Software architecture

edit

The system uses a client–server architecture. The servers maintain a key–value associative array; the clients populate this array and query it by key. Keys are up to 250 bytes long and values can be at most 1 megabyte in size.

Clients use client-side libraries to contact the servers which, by default, expose their service at port 11211. Both TCP and UDP are supported. Each client knows all servers; the servers do not communicate with each other. If a client wishes to set or read the value corresponding to a certain key, the client's library first computes a hash of the key to determine which server to use. This gives a simple form of sharding and scalable shared-nothing architecture across the servers. The server computes a second hash of the key to determine where to store or read the corresponding value. The servers keep the values in RAM (and, starting in 1.6.0, in auxiliary cache on disk using an external storage server option);[21] if a server runs out of available memory or disk, it discards the oldest values. Therefore, clients must treat Memcached as a transitory cache; they cannot assume that data stored in Memcached is still there when they need it. Other databases, such as MemcacheDB, Couchbase Server, provide persistent storage while maintaining Memcached protocol compatibility.

If all client libraries use the same hashing algorithm to determine servers, then clients can read each other's cached data.

A typical deployment has several servers and many clients. However, it is possible to use Memcached on a single computer, acting simultaneously as client and server. The size of its hash table is often very large. It is limited to available memory across all the servers in the cluster of servers in a data center. Where high-volume, wide-audience Web publishing requires it, this may stretch to many gigabytes. Memcached can be equally valuable for situations where either the number of requests for content is high, or the cost of generating a particular piece of content is high. Applications with particularly high-demand caching needs can use a built-in proxy to define and configure complex client-server routes.[21]

Security

edit

Most deployments of Memcached are within trusted networks where clients may freely connect to any server. However, sometimes Memcached is deployed in untrusted networks or where administrators want to exercise control over the clients that are connecting. For this purpose Memcached can be compiled with optional SASL authentication support. The SASL support requires the binary protocol.

A presentation at BlackHat USA 2010 revealed that a number of large public websites had left Memcached open to inspection, analysis, retrieval, and modification of data.[22]

Even within a trusted organisation, the flat trust model of memcached may have security implications. For efficient simplicity, all Memcached operations are treated equally. Clients with a valid need for access to low-security entries within the cache gain access to all entries within the cache, even when these are higher-security and that client has no justifiable need for them. If the cache key can be either predicted, guessed or found by exhaustive searching, its cache entry may be retrieved.

Some attempt to isolate setting and reading data may be made in situations such as high volume web publishing. A farm of outward-facing content servers have read access to memcached containing published pages or page components, but no write access. Where new content is published (and is not yet in memcached), a request is instead sent to content generation servers that are not publicly accessible to create the content unit and add it to memcached. The content server then retries to retrieve it and serve it outwards.

Used as a DDoS attack vector

edit

In February 2018, CloudFlare reported that misconfigured memcached servers were used to launch DDoS attacks in large scale.[23] The memcached protocol over UDP has a huge amplification factor, of more than 51000.[24] Victims of the DDoS attacks include GitHub, which was flooded with 1.35?Tbit/s peak incoming traffic.[25]

This issue was mitigated in Memcached version 1.5.6, which disabled UDP protocol by default.[26]

Example code

edit

Note that all functions described on this page are pseudocode only. Memcached calls and programming languages may vary based on the API used.

Converting database or object creation queries to use Memcached is simple. Typically, when using straight database queries, example code would be as follows:

 function get_foo(int userid)
     data = db_select("SELECT * FROM users WHERE userid =??", userid)
     return data

After conversion to Memcached, the same call might look like the following

 function get_foo(int userid)
     /* first try the cache */
     data = memcached_fetch("userrow:" + userid)
     if not data
         /* not found?: request database */
         data = db_select("SELECT * FROM users WHERE userid =??", userid)
         /* then store in cache until next get */
         memcached_add("userrow:" + userid, data)
     end

     return data

The client would first check whether a Memcached value with the unique key "userrow:userid" exists, where userid is some number. If the result does not exist, it would select from the database as usual, and set the unique key using the Memcached API add function call.

However, if only this API call were modified, the server would end up fetching incorrect data following any database update actions: the Memcached "view" of the data would become out of date. Therefore, in addition to creating an "add" call, an update call would also be needed using the Memcached set function.

 function update_foo(int userid, string dbUpdateString)
     /* first update database */
     result = db_execute(dbUpdateString)
     if result
         /* database update successful?: fetch data to be stored in cache */
         data = db_select("SELECT * FROM users WHERE userid =??", userid)
         /* the previous line could also look like data = createDataFromDBString(dbUpdateString) */
         /* then store in cache until next get */
         memcached_set("userrow:" + userid, data)

This call would update the currently cached data to match the new data in the database, assuming the database query succeeds. An alternative approach would be to invalidate the cache with the Memcached delete function, so that subsequent fetches result in a cache miss. Similar action would need to be taken when database records were deleted, to maintain either a correct or incomplete cache.

An alternate cache-invalidation strategy is to store a random number in an agreed-upon cache entry and to incorporate this number into all keys that are used to store a particular kind of entry. To invalidate all such entries at once, change the random number. Existing entries (which were stored using the old number) will no longer be referenced and so will eventually expire or be recycled.

  function store_xyz_entry(int key, string value)
      /* Retrieve the random number - use zero if none exists yet.
      *  The key-name used here is arbitrary. */ 
      seed = memcached_fetch(":xyz_seed:")
      if not seed
          seed = 0
      /* Build the key used to store the entry and store it.
      *  The key-name used here is also arbitrary. Notice that the "seed" and the user's "key"
      *  are stored as separate parts of the constructed hashKey string: ":xyz_data:(seed):(key)." 
      *  This is not mandatory, but is recommended. */
      string hashKey = sprintf(":xyz_data:%d:%d", seed, key)
      memcached_set(hashKey, value)

  /* "fetch_entry," not shown, follows identical logic to the above. */

  function invalidate_xyz_cache()
      existing_seed = memcached_fetch(":xyz_seed:")
      /* Coin a different random seed */
      do
          seed = rand()
      until seed != existing_seed
      /* Now store it in the agreed-upon place. All future requests will use this number. 
      *  Therefore, all existing entries become un-referenced and will eventually expire. */
      memcached_set(":xyz_seed:", seed)

Usage

edit

See also

edit

References

edit
  1. ^ "Release 1.6.38". 19 March 2025. Retrieved 27 March 2025.
  2. ^ a b "Memcached license". GitHub. Retrieved 2025-08-14.
  3. ^ "Google Code Archive - Long-term storage for Google Code Project Hosting". Code.google.com. Retrieved 2025-08-14.
  4. ^ "Google Code Archive - Long-term storage for Google Code Project Hosting". Code.google.com. Retrieved 2025-08-14.
  5. ^ [1]. Community.livejournal.com (2025-08-14). Retrieved on 2025-08-14.
  6. ^ [2]. Community.livejournal.com (2025-08-14). Retrieved on 2025-08-14.
  7. ^ "lj_dev: memcached". 2025-08-14. Archived from the original on 2025-08-14. Retrieved 2025-08-14.
  8. ^ Cuong Do Cuong (Engineering manager at YouTube/Google) (June 23, 2007). Seattle Conference on Scalability: YouTube Scalability (Online Video - 26th minute). Seattle: Google Tech Talks.
  9. ^ Whitaker, Keir (2025-08-14). "Steve Huffman on Lessons Learned at Reddit | Carsonified". Archived from the original on 2025-08-14. Retrieved 2025-08-14.
  10. ^ "Scaling memcached at Facebook". Facebook.com. 2025-08-14. Retrieved 2025-08-14.
  11. ^ Scaling Memcache at Facebook. USENIX. 2002. ISBN?9781931971003. Retrieved 2025-08-14.
  12. ^ "Building Pinterest in the cloud". Pinterest Careers. 2025-08-14. Retrieved 2025-08-14.
  13. ^ "A comprehensive, fast, pure-Python memcached client". Github.com. 2025-08-14. Retrieved 2025-08-14.
  14. ^ "It's Not Rocket Science, But It's Our Work". Blog.twitter.com. 2025-08-14. Retrieved 2025-08-14.
  15. ^ "memcached". MediaWiki. Retrieved 2025-08-14.
  16. ^ Rez BoF, SIGGRAPH 2019, archived from the original on 2025-08-14, retrieved 2025-08-14
  17. ^ "Memcache Examples | App Engine standard environment for Python | Google Cloud Platform". Code.google.com. 2025-08-14. Retrieved 2025-08-14.
  18. ^ "About In-Role Cache for Azure Cache". Msdn.microsoft.com. 2025-08-14. Retrieved 2025-08-14.
  19. ^ Verge, Jason (2025-08-14). "Redis Labs: We Have 3,000 Paying Cloud In-Memory NoSQL Customers". Data Center Knowledge. Retrieved 2025-08-14.
  20. ^ "AWS | Amazon ElastiCache – in-memory data store and cache". Aws.amazon.com. Retrieved 2025-08-14.
  21. ^ a b McIntosh, Jason (14 February 2025). "The evolution of Memcached". LWN. Retrieved 14 February 2025.
  22. ^ "SensePost | Blackhat write-up: Go-derper and mining memcaches". Archived from the original on 2025-08-14. Retrieved 2025-08-14.
  23. ^ "Memcrashed - Major amplification attacks from UDP port 11211". CloudFlare. 27 Feb 2018. Retrieved 3 March 2018.
  24. ^ Jeffrey, Cal (Mar 1, 2018). "GitHub falls victim to largest DDoS attack ever recorded".
  25. ^ "February 28th DDoS Incident Report". March 1, 2018. Retrieved 3 March 2018.
  26. ^ "Memcached 1.5.6 Release Notes". GitHub. 2025-08-14. Retrieved 3 March 2018.
  27. ^ "Speedy MySQL 5.6 takes aim at NoSQL, MariaDB". Theregister.co.uk. Retrieved 2025-08-14.
  28. ^ David Felcey (2025-08-14). "Getting Started With The Coherence Memcached Adaptor | Oracle Coherence Blog". Blogs.oracle.com. Archived from the original on 2025-08-14. Retrieved 2025-08-14.
  29. ^ "Using the Memcached protocol endpoint with Infinispan". infinispan.org. Retrieved 2025-08-14.
edit
海为什么是蓝色 小三阳是什么 活性炭是什么东西 腹泻是什么原因引起的 什么是七七事变
足银是什么意思 口若悬什么 饭中吃药是什么时候吃 调经止带是什么意思 X-Ray什么意思
左肾尿盐结晶是什么意思 嘴巴边上长痘痘是什么原因 痰多是什么原因造成的 通草长什么样图片 喝了藿香正气水不能吃什么
女性提高免疫力吃什么 出国需要什么手续和证件 40岁属什么 红色药片一般是什么药 怀孕一个月会有什么反应
肾上腺素是什么东西hcv8jop9ns0r.cn 肠胃炎喝什么药hcv9jop1ns0r.cn 苟不教的苟是什么意思hcv8jop8ns4r.cn 做梦梦到大蟒蛇是什么意思hcv9jop7ns3r.cn 湿疹是什么症状及图片hcv7jop6ns2r.cn
蛇喜欢吃什么食物hcv9jop4ns0r.cn 夜来香是什么花hcv9jop2ns6r.cn 漏尿吃什么药hcv8jop6ns6r.cn 鱼油有什么用hcv7jop6ns4r.cn 小孩掉头发是什么原因hcv9jop4ns8r.cn
做小月子要注意什么yanzhenzixun.com 什么是扁平足图片hcv8jop1ns3r.cn 耳朵旁边长痘痘是什么原因hcv9jop8ns2r.cn 胃酸是什么酸hcv9jop5ns8r.cn 面粉是什么粉hcv8jop6ns4r.cn
圣女是什么生肖hcv9jop3ns4r.cn 正方形纸能折什么hcv8jop8ns2r.cn 荔枝不能与什么一起吃hcv8jop3ns5r.cn 血管属于什么组织hcv8jop8ns0r.cn 88年什么命hcv8jop7ns9r.cn
百度