{"id":339,"date":"2023-02-25T06:52:14","date_gmt":"2023-02-24T22:52:14","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=339"},"modified":"2023-04-30T14:49:25","modified_gmt":"2023-04-30T06:49:25","slug":"brief-discussion-on-differences-between-ehcache-and-guava-cache","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/brief-discussion-on-differences-between-ehcache-and-guava-cache\/","title":{"rendered":"Ehcache\u4e0eGuava Cache\u7684\u533a\u522b\u6d45\u8c08"},"content":{"rendered":"<p>\u6700\u8fd1\u5728\u505a\u4e00\u4e9b\u7f13\u5b58\u6539\u9020\u7684\u573a\u666f\uff0c\u6709\u5982\u4e0b\u4e00\u4e9b\u7ecf\u9a8c\u603b\u7ed3\uff1a<\/p>\n<ul>\n<li>Ehcache\u652f\u6301\u6301\u4e45\u5316\u5230\u672c\u5730\u78c1\u76d8\uff0cGuava\u4e0d\u53ef\u4ee5<\/li>\n<li>Ehcache\u6709\u73b0\u6210\u7684\u96c6\u7fa4\u89e3\u51b3\u65b9\u6848\uff0cGuava\u6ca1\u6709\u3002\u4e0d\u8fc7\u4e2a\u4eba\u611f\u89c9\u6bd4\u8f83\u9e21\u808b\uff0c\u5bf9JVM\u7ea7\u522b\u7684\u7f13\u5b58\u6765\u8bb2\u592a\u91cd\u4e86<\/li>\n<li>Ehcache jar\u5305\u5e9e\u5927\uff0cGuava Cache\u53ea\u662fGuava jar\u5305\u4e2d\u7684\u5de5\u5177\u4e4b\u4e00\uff0c\u800c\u4e14\u540e\u8005\u8fdc\u8fdc\u5c0f\u4e8eEhcache<\/li>\n<li>\u4e24\u79cd\u7f13\u5b58\u5f53\u7f13\u5b58\u8fc7\u671f\u6216\u8005\u6ca1\u6709\u547d\u4e2d\u7684\u65f6\u5019\u90fd\u53ef\u4ee5\u901a\u8fc7load\u63a5\u53e3\u91cd\u8f7d\u6570\u636e\uff0c\u8c03\u7528\u65b9\u5f0f\u7565\u6709\u4e0d\u540c\u3002\u4e24\u8005\u7684\u4e3b\u8981\u533a\u522b\u662fEhcache\u7684\u7f13\u5b58load\u7684\u65f6\u5019\uff0c\u5141\u8bb8\u7528\u6237\u8fd4\u56denull\uff0c\u800cGuava Cache\u5219\u4e0d\u5141\u8bb8\u8fd4\u56de\u4e3anull\uff0c\u56e0\u4e3aGuava Cache\u662f\u6839\u636evalue\u7684\u503c\u662f\u5426\u4e3anull\u6765\u5224\u65ad\u662f\u5426\u9700\u8981load\uff0c\u6240\u4ee5\u4e0d\u5141\u8bb8\u8fd4\u56de\u4e3anull\uff0c\u4f46\u662f\u4f7f\u7528\u7684\u65f6\u5019\u53ef\u4ee5\u4f7f\u7528\u7a7a\u5bf9\u8c61\u66ff\u6362\u3002\u4e0d\u5141\u8bb8\u8fd4\u56denull\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u8003\u8651<\/li>\n<li>Ehcache\u6709\u5185\u5b58\u5360\u7528\u5927\u5c0f\u7edf\u8ba1\uff0cGuava Cache\u6ca1\u6709\uff0c\u9700\u8981\u81ea\u5df1\u5f00\u53d1<\/li>\n<li>Ehcache\u5728put\u7f13\u5b58\u7684\u65f6\u5019\uff0c\u5bf9K\u3001V\u90fd\u505a\u4e86\u5305\u88c5\uff0c\u5bf9GC\u6709\u4e00\u5b9a\u5f71\u54cd<\/li>\n<\/ul>\n<p><!-- more --><\/p>\n<h3>\u4ec0\u4e48\u65f6\u5019\u9002\u7528Ehcache\u3001\u4ec0\u4e48\u65f6\u5019\u9002\u7528Guava cache?<\/h3>\n<p>\u9996\u5148\uff0c\u4e24\u8005\u90fd\u662f\u5f88\u6210\u719f\u7684JVM\u7ea7\u522b\u7f13\u5b58\uff0c\u6240\u4ee5\u5728\u7edd\u5927\u591a\u6570\u60c5\u51b5\u90fd\u662f\u53ef\u4ee5\u6ee1\u8db3\u8981\u6c42\u7684<\/p>\n<h3>\u9002\u7528Ehcache\u7684\u60c5\u51b5<\/h3>\n<ul>\n<li>\u9700\u8981\u6301\u4e45\u5316\u6301\u4e45\u5316\u3002\u4f7f\u7528\u6301\u4e45\u5316\u529f\u80fd\u9700\u8981\uff0c\u7f13\u5b58\u7a33\u5b9a\uff0c\u4ee5\u514d\u6301\u4e45\u5316\u7684\u6570\u636e\u4e0d\u51c6\u786e\u5f71\u54cd\u7ed3\u679c<\/li>\n<li>\u6709\u96c6\u7fa4\u89e3\u51b3\u65b9\u6848\u3002<\/li>\n<\/ul>\n<h3>\u9002\u7528Guava cache\u7684\u60c5\u51b5<\/h3>\n<p>Guava cache\u8bf4\u7b80\u5355\u70b9\u5c31\u662f\u4e00\u4e2a\u652f\u6301LRU\u7684ConCurrentHashMap\uff0c\u5b83\u6ca1\u6709Ehcache\u90a3\u4e48\u591a\u7684\u5404\u79cd\u7279\u6027\uff0c\u53ea\u662f\u63d0\u4f9b\u4e86\u589e\u3001\u5220\u3001\u6539\u3001\u67e5\u3001\u5237\u65b0\u89c4\u5219\u548c\u65f6\u6548\u89c4\u5219\u8bbe\u5b9a\u7b49\u6700\u57fa\u672c\u7684\u5143\u7d20\u3002\u505a\u4e00\u4e2ajar\u5305\u4e2d\u7684\u4e00\u4e2a\u529f\u80fd\u4e4b\u4e00\uff0cGuava cache\u6781\u5ea6\u7b80\u6d01\u5e76\u80fd\u6ee1\u8db3\u89c9\u5927\u90e8\u5206\u4eba\u7684\u8981\u6c42<\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>Ehcache\u6709\u7740\u5168\u9762\u7684\u7f13\u5b58\u7279\u6027\uff0c\u4f46\u662f\u7565\u91cd\u3002Guava cache\u6709\u6700\u57fa\u672c\u7684\u7f13\u5b58\u7279\u6027\uff0c\u5f88\u8f7b\u3002\u5927\u5bb6\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u4f7f\u7528<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728\u505a\u4e00\u4e9b\u7f13\u5b58\u6539\u9020\u7684\u573a\u666f\uff0c\u6709\u5982\u4e0b\u4e00\u4e9b\u7ecf\u9a8c\u603b\u7ed3\uff1a Ehcache\u652f\u6301\u6301\u4e45\u5316\u5230\u672c\u5730\u78c1\u76d8\uff0cGuava\u4e0d\u53ef\u4ee5 Ehc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[112,113],"class_list":["post-339","post","type-post","status-publish","format-standard","hentry","category-java-basic","tag-ehcache","tag-guava"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=339"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}