{"id":1290,"date":"2018-02-24T16:39:55","date_gmt":"2018-02-24T08:39:55","guid":{"rendered":"http:\/\/www.yeetrack.com\/?p=1290"},"modified":"2024-01-09T16:23:59","modified_gmt":"2024-01-09T08:23:59","slug":"jodd%e4%b8%ad%e7%9a%84%e7%bc%93%e5%ad%98","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=1290","title":{"rendered":"jodd\u4e2d\u7684\u7f13\u5b58"},"content":{"rendered":"<p>Jodd\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u8f7b\u91cf\u7ea7\u7684\u9002\u7528\u4e8eweb\u5f00\u53d1\u7684\u5de5\u5177\u96c6\u5408\u3002\u5305\u5927\u5c0f\u53ea\u67091M\uff0c\u4f7f\u7528\u8d85\u7ea7\u7b80\u5355\u3002\u5176\u5b9ejodd\u7684\u6587\u6863\u5199\u7684\u4e0d\u5168\uff0c\u53ea\u4ecb\u7ecd\u4e86\u4e00\u90e8\u5206\u7684\u529f\u80fd\uff0c\u6709\u4e9b\u5de5\u5177\u7c7b\u6ca1\u6709\u4ecb\u7ecd\u3002\u5728\u7ffb\u770bjodd\u6e90\u7801\u65f6\uff0c\u770b\u5230jodd\u5c01\u88c5\u4e86Cache\uff0c\u4f7f\u7528\u8d77\u6765\u975e\u5e38\u7b80\u5355\u3002\u5728\u8fd9\u91cc\u7b80\u5355\u4ecb\u7ecd\u4e0b\u3002<\/p>\n<p>jodd\u7684Cache\u7c7b\u5728<code>jodd-core<\/code>jar\u5305\u4e2d\uff0c\u5b9e\u73b0\u7684\u7f13\u5b58\u6709\u5148\u8fdb\u5148\u51fa(FIFO)\u3001\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\uff08LFU\uff09\u3001\u6700\u8fd1\u6700\u4e45\u672a\u4f7f\u7528\uff08LRU\uff09\u3001\u57fa\u4e8e\u65f6\u95f4\u7684\u7f13\u5b58\u3002<br \/>\n<!--more--><\/p>\n<h2>FIFO<\/h2>\n<p>\u5f88\u7b80\u5355\u7684\u7f13\u5b58\uff0c\u5c31\u662f\u4e00\u4e2a\u6307\u5b9a\u5927\u5c0f\u7684\u961f\u5217\uff0c\u5b58\u653e\u7684\u65f6\u5019\uff0c\u5982\u679c\u961f\u5217\u5df2\u7ecf\u6ee1\u4e86\uff0c\u5c31\u6dd8\u6c70\u6700\u65e9\u7684\u7f13\u5b58\u3002<\/p>\n<pre><code>    \/\/\u5148\u8fdb\u5148\u51fa\u961f\u5217\uff0c\u961f\u5217\u5927\u5c0f100\uff0c\u7f13\u5b58\u65f6\u95f4\u8bbe\u7f6e\u4e3a5\u79d2\u949f\n    FIFOCache&lt;string ,String&gt; fifoCache = new FIFOCache&lt;&gt;(100, 5 * 1000);\n    fifoCache.put(\"aaa\", \"some value\");\n    fifoCache.put(\"bbb\", \"some value\");\n    System.out.println(fifoCache.get(\"aaa\"));\n<\/code><\/pre>\n<h2>LFU<\/h2>\n<p>\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\uff0c\u7edf\u8ba1\u4e00\u6bb5\u65f6\u95f4\u5185\uff0c\u88ab\u8bbf\u95ee\u6b21\u6570\u6700\u5c11\u7684\u7f13\u5b58\uff0c\u6700\u5148\u88ab\u6dd8\u6c70\u3002<\/p>\n<pre><code>    LFUCache lfuCache = new LFUCache(100, 5 * 1000);\n    lfuCache.put(\"aaa\", \"some value\");\n    lfuCache.put(\"bbb\", \"some value\");\n    System.out.println(lfuCache.get(\"aaa\"));\n<\/code><\/pre>\n<h2>LRU<\/h2>\n<p>\u6700\u8fd1\u6700\u4e45\u672a\u88ab\u4f7f\u7528\uff0c\u6700\u8fd1\u4e00\u6bb5\u65f6\u95f4\uff0c\u6ca1\u6709\u88ab\u8bbf\u95ee\u7684\u7f13\u5b58\uff0c\u6700\u5148\u88ab\u6dd8\u6c70\u3002<\/p>\n<pre><code>    LRUCache&lt;\/string&gt;&lt;string ,String&gt; lruCache = new LRUCache&lt;\/string&gt;&lt;string , String&gt;(100, 5*1000);\n    lruCache.put(\"aaa\", \"some value\");\n    lruCache.put(\"bbb\", \"some value\");\n    System.out.println(lruCache.get(\"aaa\"));\n<\/code><\/pre>\n<h2>TimedCache<\/h2>\n<p>\u57fa\u4e8e\u65f6\u95f4\u7684\u7f13\u5b58\uff0c\u5c31\u662f\u8bbe\u7f6e\u4e00\u4e2a\u5931\u6548\u65f6\u95f4\uff0c\u5982\u679c\u65f6\u95f4\u8fc7\u671f\u4e86\uff0c\u7f13\u5b58\u5c31\u4f1a\u88ab\u5220\u9664\u3002<\/p>\n<pre><code>    TimedCache&lt;\/string&gt;&lt;string ,String&gt; timedCache = new TimedCache&lt;&gt;(5*1000);\n    timedCache.schedulePrune(1000);  \/\/\u4e00\u79d2\u949f\u626b\u63cf\u4e00\u6b21,\u5982\u679c\u7f13\u5b58\u8fc7\u671f,\u5c31\u5220\u9664\n    timedCache.put(\"aaa\", \"some value\");\n    timedCache.put(\"bbb\", \"some value\");\n    System.out.println(timedCache.get(\"aaa\"));&lt;\/string&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Jodd\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u8f7b\u91cf\u7ea7\u7684\u9002\u7528\u4e8eweb\u5f00\u53d1\u7684\u5de5\u5177\u96c6\u5408\u3002\u5305\u5927\u5c0f\u53ea\u67091M\uff0c\u4f7f\u7528\u8d85\u7ea7\u7b80\u5355\u3002\u5176\u5b9ejodd\u7684\u6587\u6863\u5199\u7684\u4e0d\u5168\uff0c\u53ea\u4ecb\u7ecd\u4e86\u4e00\u90e8\u5206\u7684\u529f\u80fd\uff0c\u6709\u4e9b\u5de5\u5177\u7c7b\u6ca1\u6709\u4ecb\u7ecd\u3002\u5728\u7ffb\u770bjodd\u6e90\u7801\u65f6\uff0c\u770b\u5230jodd\u5c01\u88c5\u4e86C&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[33],"tags":[8],"class_list":["post-1290","post","type-post","status-publish","format-standard","hentry","category-coding","tag-java"],"views":4954,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1290"}],"version-history":[{"count":2,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1290\/revisions"}],"predecessor-version":[{"id":1292,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1290\/revisions\/1292"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}