{"id":9966,"date":"2025-04-18T17:43:37","date_gmt":"2025-04-18T09:43:37","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/9966.html"},"modified":"2025-04-18T17:43:37","modified_gmt":"2025-04-18T09:43:37","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%bc%93%e5%ad%98%e5%8c%ba%e7%9a%84%e8%bf%87%e6%9c%9f%e5%88%a0%e9%99%a4%e7%ad%96%e7%95%a5%ef%bc%9a%e5%8e%9f%e7%90%86%e4%b8%8e%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/9966.html","title":{"rendered":"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0"},"content":{"rendered":"<p>\u5728\u73b0\u4ee3\u670d\u52a1\u5668\u67b6\u6784\u4e2d&#xff0c;\u7f13\u5b58\u533a\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\u3002\u5b83\u80fd\u591f\u663e\u8457\u63d0\u5347\u6570\u636e\u8bbf\u95ee\u901f\u5ea6&#xff0c;\u51cf\u8f7b\u540e\u7aef\u6570\u636e\u5e93\u6216\u670d\u52a1\u7684\u538b\u529b\u3002\u7136\u800c&#xff0c;\u7f13\u5b58\u533a\u5e76\u975e\u4e07\u80fd&#xff0c;\u5982\u679c\u7ba1\u7406\u4e0d\u5f53&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u7f13\u5b58\u6570\u636e\u8fc7\u671f\u3001\u5360\u7528\u8fc7\u591a\u5185\u5b58&#xff0c;\u751a\u81f3\u5f15\u53d1\u6027\u80fd\u95ee\u9898\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u7f13\u5b58\u533a\u4e2d\u8fc7\u671f\u5220\u9664\u7f13\u5b58\u7684\u7b56\u7565\u548c\u5b9e\u73b0\u65b9\u6cd5&#xff0c;\u5e2e\u52a9\u8bfb\u8005\u7406\u89e3\u8fd9\u4e00\u5173\u952e\u673a\u5236\u3002<\/p>\n<h3>\u4e00\u3001\u7f13\u5b58\u533a\u7684\u4f5c\u7528\u4e0e\u6311\u6218<\/h3>\n<h4>1. \u7f13\u5b58\u533a\u7684\u4f5c\u7528<\/h4>\n<p>\u7f13\u5b58\u533a\u662f\u4e00\u79cd\u4e34\u65f6\u5b58\u50a8\u533a\u57df&#xff0c;\u7528\u4e8e\u5b58\u50a8\u9891\u7e41\u8bbf\u95ee\u7684\u6570\u636e\u3002\u901a\u8fc7\u5c06\u6570\u636e\u7f13\u5b58\u5230\u5185\u5b58\u4e2d&#xff0c;\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5bf9\u540e\u7aef\u5b58\u50a8\u7cfb\u7edf\u7684\u8bbf\u95ee\u6b21\u6570&#xff0c;\u4ece\u800c\u63d0\u9ad8\u7cfb\u7edf\u7684\u54cd\u5e94\u901f\u5ea6\u548c\u541e\u5410\u91cf\u3002\u4f8b\u5982&#xff0c;\u5728Web\u670d\u52a1\u5668\u4e2d&#xff0c;\u7f13\u5b58\u533a\u53ef\u4ee5\u5b58\u50a8\u9759\u6001\u8d44\u6e90&#xff08;\u5982\u56fe\u7247\u3001CSS\u6587\u4ef6\u3001JavaScript\u6587\u4ef6\u7b49&#xff09;&#xff0c;\u4ee5\u4fbf\u5feb\u901f\u54cd\u5e94\u7528\u6237\u7684\u8bf7\u6c42\u3002<\/p>\n<h4>2. \u7f13\u5b58\u533a\u7684\u6311\u6218<\/h4>\n<p>\u5c3d\u7ba1\u7f13\u5b58\u533a\u5e26\u6765\u4e86\u8bf8\u591a\u597d\u5904&#xff0c;\u4f46\u4e5f\u5b58\u5728\u4e00\u4e9b\u6311\u6218&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7f13\u5b58\u6570\u636e\u8fc7\u671f&#xff1a;\u7f13\u5b58\u7684\u6570\u636e\u53ef\u80fd\u4f1a\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u800c\u53d8\u5f97\u8fc7\u65f6\u3002\u4f8b\u5982&#xff0c;\u5546\u54c1\u4ef7\u683c\u3001\u7528\u6237\u4fe1\u606f\u7b49\u6570\u636e\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316&#xff0c;\u5982\u679c\u7f13\u5b58\u533a\u4e2d\u7684\u6570\u636e\u672a\u53ca\u65f6\u66f4\u65b0&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u7528\u6237\u83b7\u53d6\u5230\u9519\u8bef\u7684\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p>\u5185\u5b58\u5360\u7528&#xff1a;\u7f13\u5b58\u533a\u4f1a\u5360\u7528\u670d\u52a1\u5668\u7684\u5185\u5b58\u8d44\u6e90\u3002\u5982\u679c\u7f13\u5b58\u7684\u6570\u636e\u8fc7\u591a&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5185\u5b58\u4e0d\u8db3&#xff0c;\u5f71\u54cd\u670d\u52a1\u5668\u7684\u6027\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p>\u7f13\u5b58\u4e00\u81f4\u6027&#xff1a;\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d&#xff0c;\u591a\u4e2a\u670d\u52a1\u5668\u53ef\u80fd\u7f13\u5b58\u76f8\u540c\u7684\u6570\u636e\u3002\u5982\u679c\u6570\u636e\u66f4\u65b0\u540e&#xff0c;\u7f13\u5b58\u533a\u4e2d\u7684\u6570\u636e\u672a\u80fd\u53ca\u65f6\u540c\u6b65&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u7f13\u5b58\u533a\u8fc7\u671f\u5220\u9664\u7b56\u7565<\/h3>\n<h4>1. \u57fa\u4e8e\u65f6\u95f4\u7684\u8fc7\u671f\u7b56\u7565&#xff08;TTL&#xff09;<\/h4>\n<p>\u539f\u7406&#xff1a;\u57fa\u4e8e\u65f6\u95f4\u7684\u8fc7\u671f\u7b56\u7565&#xff08;Time To Live&#xff0c;TTL&#xff09;\u662f\u6700\u5e38\u89c1\u7684\u7f13\u5b58\u8fc7\u671f\u7b56\u7565\u3002\u6bcf\u4e2a\u7f13\u5b58\u9879\u5728\u521b\u5efa\u65f6\u90fd\u4f1a\u88ab\u5206\u914d\u4e00\u4e2a\u8fc7\u671f\u65f6\u95f4&#xff0c;\u5f53\u7f13\u5b58\u9879\u7684\u751f\u5b58\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u503c\u65f6&#xff0c;\u5b83\u5c06\u88ab\u81ea\u52a8\u5220\u9664\u3002<\/p>\n<p>\u5b9e\u73b0\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4&#xff1a;\u5728\u7f13\u5b58\u9879\u521b\u5efa\u65f6&#xff0c;\u8bbe\u7f6e\u4e00\u4e2a\u8fc7\u671f\u65f6\u95f4\u6233\u3002<\/p>\n<\/li>\n<li>\n<p>\u68c0\u67e5\u8fc7\u671f&#xff1a;\u5728\u6bcf\u6b21\u8bbf\u95ee\u7f13\u5b58\u9879\u65f6&#xff0c;\u68c0\u67e5\u5f53\u524d\u65f6\u95f4\u662f\u5426\u8d85\u8fc7\u8fc7\u671f\u65f6\u95f4\u6233\u3002\u5982\u679c\u8d85\u8fc7&#xff0c;\u5219\u5220\u9664\u8be5\u7f13\u5b58\u9879\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff08;C&#043;&#043;&#xff09;&#xff1a;<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unordered_map&gt;<br \/>\n#include &lt;chrono&gt;<\/p>\n<p>using namespace std;<\/p>\n<p>class Cache {<br \/>\nprivate:<br \/>\n    unordered_map&lt;string, pair&lt;string, chrono::steady_clock::time_point&gt;&gt; cache;<\/p>\n<p>public:<br \/>\n    void set(const string&amp; key, const string&amp; value, int ttl) {<br \/>\n        auto now &#061; chrono::steady_clock::now();<br \/>\n        cache[key] &#061; make_pair(value, now &#043; chrono::seconds(ttl));<br \/>\n    }<\/p>\n<p>    string get(const string&amp; key) {<br \/>\n        auto now &#061; chrono::steady_clock::now();<br \/>\n        if (cache.find(key) !&#061; cache.end() &amp;&amp; cache[key].second &gt; now) {<br \/>\n            return cache[key].first;<br \/>\n        } else {<br \/>\n            cache.erase(key);<br \/>\n            return &#034;Cache expired or not found&#034;;<br \/>\n        }<br \/>\n    }<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    Cache cache;<br \/>\n    cache.set(&#034;key1&#034;, &#034;value1&#034;, 5); \/\/ \u8bbe\u7f6e\u7f13\u5b58&#xff0c;TTL\u4e3a5\u79d2<br \/>\n    cout &lt;&lt; cache.get(&#034;key1&#034;) &lt;&lt; endl; \/\/ \u8f93\u51fa&#xff1a;value1<br \/>\n    this_thread::sleep_for(chrono::seconds(6));<br \/>\n    cout &lt;&lt; cache.get(&#034;key1&#034;) &lt;&lt; endl; \/\/ \u8f93\u51fa&#xff1a;Cache expired or not found<br \/>\n    return 0;<br \/>\n} <\/p>\n<h4>2. \u57fa\u4e8e\u8bbf\u95ee\u9891\u7387\u7684\u8fc7\u671f\u7b56\u7565&#xff08;LFU&#xff09;<\/h4>\n<p>\u539f\u7406&#xff1a;\u57fa\u4e8e\u8bbf\u95ee\u9891\u7387\u7684\u8fc7\u671f\u7b56\u7565&#xff08;Least Frequently Used&#xff0c;LFU&#xff09;\u4f1a\u5220\u9664\u8bbf\u95ee\u9891\u7387\u6700\u4f4e\u7684\u7f13\u5b58\u9879\u3002\u8fd9\u79cd\u7b56\u7565\u9002\u7528\u4e8e\u7f13\u5b58\u533a\u4e2d\u5b58\u5728\u5927\u91cf\u4e0d\u5e38\u8bbf\u95ee\u7684\u6570\u636e\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u5b9e\u73b0\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8bb0\u5f55\u8bbf\u95ee\u9891\u7387&#xff1a;\u4e3a\u6bcf\u4e2a\u7f13\u5b58\u9879\u8bb0\u5f55\u5176\u8bbf\u95ee\u6b21\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u5220\u9664\u7b56\u7565&#xff1a;\u5f53\u7f13\u5b58\u533a\u6ee1\u65f6&#xff0c;\u5220\u9664\u8bbf\u95ee\u9891\u7387\u6700\u4f4e\u7684\u7f13\u5b58\u9879\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff08;C&#043;&#043;&#xff09;&#xff1a;<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unordered_map&gt;<br \/>\n#include &lt;list&gt;<br \/>\n#include &lt;algorithm&gt;<\/p>\n<p>using namespace std;<\/p>\n<p>class LFUCache {<br \/>\nprivate:<br \/>\n    unordered_map&lt;string, pair&lt;string, int&gt;&gt; cache;<br \/>\n    unordered_map&lt;string, list&lt;int&gt;::iterator&gt; freq_map;<br \/>\n    list&lt;int&gt; freq_list;<\/p>\n<p>public:<br \/>\n    void set(const string&amp; key, const string&amp; value, int freq) {<br \/>\n        if (cache.find(key) !&#061; cache.end()) {<br \/>\n            freq_map[key]&#043;&#043;;<br \/>\n        } else {<br \/>\n            cache[key] &#061; make_pair(value, freq);<br \/>\n            freq_map[key] &#061; freq_list.begin();<br \/>\n        }<br \/>\n    }<\/p>\n<p>    string get(const string&amp; key) {<br \/>\n        if (cache.find(key) !&#061; cache.end()) {<br \/>\n            freq_map[key]&#043;&#043;;<br \/>\n            return cache[key].first;<br \/>\n        } else {<br \/>\n            return &#034;Cache not found&#034;;<br \/>\n        }<br \/>\n    }<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    LFUCache cache;<br \/>\n    cache.set(&#034;key1&#034;, &#034;value1&#034;, 1);<br \/>\n    cache.set(&#034;key2&#034;, &#034;value2&#034;, 1);<br \/>\n    cout &lt;&lt; cache.get(&#034;key1&#034;) &lt;&lt; endl; \/\/ \u8f93\u51fa&#xff1a;value1<br \/>\n    cache.set(&#034;key3&#034;, &#034;value3&#034;, 1);<br \/>\n    cout &lt;&lt; cache.get(&#034;key2&#034;) &lt;&lt; endl; \/\/ \u8f93\u51fa&#xff1a;Cache not found<br \/>\n    return 0;<br \/>\n} <\/p>\n<h4>3. \u57fa\u4e8e\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684\u8fc7\u671f\u7b56\u7565&#xff08;LRU&#xff09;<\/h4>\n<p>\u539f\u7406&#xff1a;\u57fa\u4e8e\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684\u8fc7\u671f\u7b56\u7565&#xff08;Least Recently Used&#xff0c;LRU&#xff09;\u4f1a\u5220\u9664\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684\u7f13\u5b58\u9879\u3002\u8fd9\u79cd\u7b56\u7565\u9002\u7528\u4e8e\u7f13\u5b58\u533a\u4e2d\u5b58\u5728\u5927\u91cf\u957f\u65f6\u95f4\u672a\u88ab\u8bbf\u95ee\u7684\u6570\u636e\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u5b9e\u73b0\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8bb0\u5f55\u8bbf\u95ee\u65f6\u95f4&#xff1a;\u4e3a\u6bcf\u4e2a\u7f13\u5b58\u9879\u8bb0\u5f55\u5176\u6700\u8fd1\u4e00\u6b21\u88ab\u8bbf\u95ee\u7684\u65f6\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p>\u5220\u9664\u7b56\u7565&#xff1a;\u5f53\u7f13\u5b58\u533a\u6ee1\u65f6&#xff0c;\u5220\u9664\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684\u7f13\u5b58\u9879\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff08;C&#043;&#043;&#xff09;&#xff1a;<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unordered_map&gt;<br \/>\n#include &lt;list&gt;<br \/>\n#include &lt;algorithm&gt;<\/p>\n<p>using namespace std;<\/p>\n<p>class LRUCache {<br \/>\nprivate:<br \/>\n    unordered_map&lt;string, pair&lt;string, chrono::steady_clock::time_point&gt;&gt; cache;<br \/>\n    list&lt;string&gt; lru_list;<\/p>\n<p>public:<br \/>\n    void set(const string&amp; key, const string&amp; value) {<br \/>\n        if (cache.find(key) !&#061; cache.end()) {<br \/>\n            lru_list.erase(find(lru_list.begin(), lru_list.end(), key));<br \/>\n        } else {<br \/>\n            if (lru_list.size() &gt;&#061; max_size) {<br \/>\n                string oldest_key &#061; lru_list.back();<br \/>\n                lru_list.pop_back();<br \/>\n                cache.erase(oldest_key);<br \/>\n            }<br \/>\n        }<br \/>\n        lru_list.push_front(key);<br \/>\n        cache[key] &#061; make_pair(value, chrono::steady_clock::now());<br \/>\n    }<\/p>\n<p>    string get(const string&amp; key) {<br \/>\n        if (cache.find(key) !&#061; cache.end()) {<br \/>\n            lru_list.erase(find(lru_list.begin(), lru_list.end(), key));<br \/>\n            lru_list.push_front(key);<br \/>\n            return cache[key].first;<br \/>\n        } else {<br \/>\n            return &#034;Cache not found&#034;;<br \/>\n        }<br \/>\n    }<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    LRUCache cache;<br \/>\n    cache.set(&#034;key1&#034;, &#034;value1&#034;);<br \/>\n    cache.set(&#034;key2&#034;, &#034;value2&#034;);<br \/>\n    cout &lt;&lt; cache.get(&#034;key1&#034;) &lt;&lt; endl; \/\/ \u8f93\u51fa&#xff1a;value1<br \/>\n    cache.set(&#034;key3&#034;, &#034;value3&#034;);<br \/>\n    cout &lt;&lt; cache.get(&#034;key2&#034;) &lt;&lt; endl; \/\/ \u8f93\u51fa&#xff1a;Cache not found<br \/>\n    return 0;<br \/>\n} <\/p>\n<h3>\u4e09\u3001\u63a8\u8350\u7684C&#043;&#043;\u5e93<\/h3>\n<h4>1.\u00a0Boost.Interprocess<\/h4>\n<p>\u7b80\u4ecb&#xff1a;Boost.Interprocess \u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u5171\u4eab\u5185\u5b58\u3001\u6587\u4ef6\u6620\u5c04\u548c\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u7f13\u5b58\u7ba1\u7406\u529f\u80fd&#xff0c;\u652f\u6301\u591a\u79cd\u7f13\u5b58\u8fc7\u671f\u7b56\u7565\u3002<\/p>\n<p>\u7279\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u652f\u6301\u591a\u79cd\u7f13\u5b58\u8fc7\u671f\u7b56\u7565&#xff08;TTL\u3001LRU\u3001LFU&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u63d0\u4f9b\u7ebf\u7a0b\u5b89\u5168\u7684\u7f13\u5b58\u7ba1\u7406\u3002<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u8de8\u8fdb\u7a0b\u5171\u4eab\u7f13\u5b58\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff1a;<\/p>\n<p>#include &lt;boost\/interprocess\/shared_memory_object.hpp&gt;<br \/>\n#include &lt;boost\/interprocess\/mapped_region.hpp&gt;<br \/>\n#include &lt;iostream&gt;<\/p>\n<p>using namespace boost::interprocess;<\/p>\n<p>int main() {<br \/>\n    \/\/ \u521b\u5efa\u5171\u4eab\u5185\u5b58\u5bf9\u8c61<br \/>\n    shared_memory_object shm(create_only, &#034;MySharedMemory&#034;, read_write);<br \/>\n    shm.truncate(1024);<\/p>\n<p>    \/\/ \u6620\u5c04\u5171\u4eab\u5185\u5b58<br \/>\n    mapped_region region(shm, read_write);<\/p>\n<p>    \/\/ \u4f7f\u7528\u5171\u4eab\u5185\u5b58<br \/>\n    char* data &#061; static_cast&lt;char*&gt;(region.get_address());<br \/>\n    strcpy(data, &#034;Hello, World!&#034;);<\/p>\n<p>    return 0;<br \/>\n} <\/p>\n<h4>2.\u00a0Folly<\/h4>\n<p>\u7b80\u4ecb&#xff1a;Folly \u662f Facebook \u5f00\u6e90\u7684\u4e00\u5957 C&#043;&#043; \u5e93&#xff0c;\u5305\u542b\u4e86\u8bb8\u591a\u9ad8\u6548\u7684\u5de5\u5177\u548c\u7ec4\u4ef6\u3002\u5176\u4e2d\u7684 folly::Cache \u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u7f13\u5b58\u7ba1\u7406\u529f\u80fd\u3002<\/p>\n<p>\u7279\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u652f\u6301\u591a\u79cd\u7f13\u5b58\u8fc7\u671f\u7b56\u7565&#xff08;TTL\u3001LRU\u3001LFU&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u63d0\u4f9b\u7ebf\u7a0b\u5b89\u5168\u7684\u7f13\u5b58\u7ba1\u7406\u3002<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff1a;<\/p>\n<p>#include &lt;folly\/CachedIO.h&gt;<br \/>\n#include &lt;folly\/Singleton.h&gt;<br \/>\n#include &lt;folly\/ThreadLocal.h&gt;<br \/>\n#include &lt;iostream&gt;<\/p>\n<p>using namespace folly;<\/p>\n<p>int main() {<br \/>\n    \/\/ \u521b\u5efa\u7f13\u5b58<br \/>\n    CachedIO cache;<\/p>\n<p>    \/\/ \u8bbe\u7f6e\u7f13\u5b58<br \/>\n    cache.set(&#034;key1&#034;, &#034;value1&#034;);<\/p>\n<p>    \/\/ \u83b7\u53d6\u7f13\u5b58<br \/>\n    string value &#061; cache.get(&#034;key1&#034;);<br \/>\n    cout &lt;&lt; value &lt;&lt; endl; \/\/ \u8f93\u51fa&#xff1a;value1<\/p>\n<p>    return 0;<br \/>\n} <\/p>\n<h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<p>\u7f13\u5b58\u533a\u662f\u670d\u52a1\u5668\u67b6\u6784\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206&#xff0c;\u4f46\u7ba1\u7406\u4e0d\u5f53\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684\u8fc7\u671f\u5220\u9664\u89c4\u5219&#xff0c;\u53ef\u4ee5\u786e\u4fdd\u7f13\u5b58\u533a\u4e2d\u7684\u6570\u636e\u59cb\u7ec8\u662f\u6700\u65b0\u7684&#xff0c;\u540c\u65f6\u907f\u514d\u5185\u5b58\u5360\u7528\u8fc7\u591a\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u51e0\u79cd\u5e38\u89c1\u7684\u7f13\u5b58\u8fc7\u671f\u5220\u9664\u7b56\u7565&#xff08;TTL\u3001LRU\u3001LFU&#xff09;&#xff0c;\u5e76\u63d0\u4f9b\u4e86\u76f8\u5e94\u7684\u5b9e\u73b0\u65b9\u6cd5\u548c\u793a\u4f8b\u4ee3\u7801\u3002\u5e0c\u671b\u8bfb\u8005\u80fd\u591f\u901a\u8fc7\u672c\u6587\u638c\u63e1\u7f13\u5b58\u533a\u7ba1\u7406\u7684\u5173\u952e\u601d\u8def&#xff0c;\u5e76\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u52a0\u4ee5\u8fd0\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u7f13\u5b58\u533a\u662f\u670d\u52a1\u5668\u67b6\u6784\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\uff0c\u4f46\u7ba1\u7406\u4e0d\u5f53\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684\u8fc7\u671f\u5220\u9664\u89c4\u5219\uff0c\u53ef\u4ee5\u786e\u4fdd\u7f13\u5b58\u533a\u4e2d\u7684\u6570\u636e\u59cb\u7ec8\u662f\u6700\u65b0\u7684\uff0c\u540c\u65f6\u907f\u514d\u5185\u5b58\u5360\u7528\u8fc7\u591a\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u51e0\u79cd\u5e38\u89c1\u7684\u7f13\u5b58\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff08TTL\u3001LRU\u3001LFU\uff09\uff0c\u5e76\u63d0\u4f9b\u4e86\u76f8\u5e94\u7684\u5b9e\u73b0\u65b9\u6cd5\u548c\u793a\u4f8b\u4ee3\u7801\u3002\u5e0c\u671b\u8bfb\u8005\u80fd\u591f\u901a\u8fc7\u672c\u6587\u638c\u63e1\u7f13\u5b58\u533a\u7ba1\u7406\u7684\u5173\u952e\u601d\u8def\uff0c\u5e76\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u52a0\u4ee5\u8fd0\u7528\u3002_\u7f13\u5b58\u8fc7\u671f\u65f6\u95f4\u5220\u9664\u539f\u7406<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,397,43,398,396],"topic":[],"class_list":{"0":"post-9966","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-server","7":"tag-c","9":"tag-43","10":"tag-398","11":"tag-396"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/9966.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u7f13\u5b58\u533a\u662f\u670d\u52a1\u5668\u67b6\u6784\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\uff0c\u4f46\u7ba1\u7406\u4e0d\u5f53\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684\u8fc7\u671f\u5220\u9664\u89c4\u5219\uff0c\u53ef\u4ee5\u786e\u4fdd\u7f13\u5b58\u533a\u4e2d\u7684\u6570\u636e\u59cb\u7ec8\u662f\u6700\u65b0\u7684\uff0c\u540c\u65f6\u907f\u514d\u5185\u5b58\u5360\u7528\u8fc7\u591a\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u51e0\u79cd\u5e38\u89c1\u7684\u7f13\u5b58\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff08TTL\u3001LRU\u3001LFU\uff09\uff0c\u5e76\u63d0\u4f9b\u4e86\u76f8\u5e94\u7684\u5b9e\u73b0\u65b9\u6cd5\u548c\u793a\u4f8b\u4ee3\u7801\u3002\u5e0c\u671b\u8bfb\u8005\u80fd\u591f\u901a\u8fc7\u672c\u6587\u638c\u63e1\u7f13\u5b58\u533a\u7ba1\u7406\u7684\u5173\u952e\u601d\u8def\uff0c\u5e76\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u52a0\u4ee5\u8fd0\u7528\u3002_\u7f13\u5b58\u8fc7\u671f\u65f6\u95f4\u5220\u9664\u539f\u7406\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/9966.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T09:43:37+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/9966.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/9966.html\",\"name\":\"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T09:43:37+00:00\",\"dateModified\":\"2025-04-18T09:43:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/9966.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/9966.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/9966.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/9966.html","og_locale":"zh_CN","og_type":"article","og_title":"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u7f13\u5b58\u533a\u662f\u670d\u52a1\u5668\u67b6\u6784\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\uff0c\u4f46\u7ba1\u7406\u4e0d\u5f53\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684\u8fc7\u671f\u5220\u9664\u89c4\u5219\uff0c\u53ef\u4ee5\u786e\u4fdd\u7f13\u5b58\u533a\u4e2d\u7684\u6570\u636e\u59cb\u7ec8\u662f\u6700\u65b0\u7684\uff0c\u540c\u65f6\u907f\u514d\u5185\u5b58\u5360\u7528\u8fc7\u591a\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u51e0\u79cd\u5e38\u89c1\u7684\u7f13\u5b58\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff08TTL\u3001LRU\u3001LFU\uff09\uff0c\u5e76\u63d0\u4f9b\u4e86\u76f8\u5e94\u7684\u5b9e\u73b0\u65b9\u6cd5\u548c\u793a\u4f8b\u4ee3\u7801\u3002\u5e0c\u671b\u8bfb\u8005\u80fd\u591f\u901a\u8fc7\u672c\u6587\u638c\u63e1\u7f13\u5b58\u533a\u7ba1\u7406\u7684\u5173\u952e\u601d\u8def\uff0c\u5e76\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u52a0\u4ee5\u8fd0\u7528\u3002_\u7f13\u5b58\u8fc7\u671f\u65f6\u95f4\u5220\u9664\u539f\u7406","og_url":"https:\/\/www.wsisp.com\/helps\/9966.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T09:43:37+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/9966.html","url":"https:\/\/www.wsisp.com\/helps\/9966.html","name":"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T09:43:37+00:00","dateModified":"2025-04-18T09:43:37+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/9966.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/9966.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/9966.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u670d\u52a1\u5668\u7f13\u5b58\u533a\u7684\u8fc7\u671f\u5220\u9664\u7b56\u7565\uff1a\u539f\u7406\u4e0e\u5b9e\u73b0"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/9966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=9966"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/9966\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=9966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=9966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=9966"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=9966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}