第ä¸ç« 常ç¨çç¼åææ¯
1ã常è§ç两ç§ç¼å
æ¬å°ç¼åï¼ä¸éè¦åºååï¼é度快ï¼ç¼åçæ°éä¸å¤§å°åéäºæ¬æºå
å
åå¸å¼ç¼åï¼éè¦åºååï¼é度ç¸è¾äºæ¬å°ç¼åè¾æ
¢ï¼ä½æ¯ç论ä¸ç¼åçæ°éä¸å¤§å°æ éï¼å 为ç¼åæºå¨å¯ä»¥ä¸ææ©å±ï¼
2ãæ¬å°ç¼å
Google guava cacheï¼å½ä¸æ好ç¨çæ¬å°ç¼å
Ehcacheï¼springé»è®¤éæçä¸ä¸ªç¼åï¼ä»¥spring cacheçåºå±ç¼åå®ç°ç±»å½¢å¼å»æä½ç¼åçè¯ï¼é常æ¹ä¾¿ï¼ä½æ¯æ¬ 缺çµæ´»ï¼å¦ææ³è¦çµæ´»ä½¿ç¨ï¼è¿æ¯è¦åç¬ä½¿ç¨Ehcache
Oscacheï¼æç»å
¸ç®åç页é¢ç¼å
3ãåå¸å¼ç¼å
memcachedï¼åå¸å¼ç¼åçæ é
Redisï¼æ°ä¸ä»£çåå¸å¼ç¼åï¼ææ¿ä»£memcachedçè¶å¿
3.1ãmemcached
ç»å
¸çä¸è´æ§hashç®æ³
åºäºslabçå
å模åææé²æ¢å
åç¢çç产çï¼ä½åæ¶ä¹éè¦ä¼°è®¡å¥½å¯å¨åæ°ï¼å¦åä¼æµªè´¹å¾å¤çå
åï¼
é群ä¸æºå¨ä¹é´äºä¸éä¿¡ï¼ç¸è¾äºJboss cacheçé群ä¸æºå¨ä¹é´çç¸äºéä¿¡çç¼åï¼é度æ´å¿«<--å 为å°äºåæ¥æ´æ°ç¼åçå¼éï¼ä¸æ´éåäºå¤§ååå¸å¼ç³»ç»ä¸ä½¿ç¨ï¼
使ç¨æ¹ä¾¿ï¼è¿ä¸ç¹æ¯ç¸è¾äºRediså¨æ建客æ·ç«¯çæ¶åèè¨çï¼å°½ç®¡redisç使ç¨ä¹ä¸å°é¾ï¼
å¾ä¸ä¸ï¼ä¸åç¼åï¼è¿ä¸ç¹ä¹æ¯ç¸è¾äºRedisèè¨çï¼
3.2ãRedis
å¯ä»¥åå¨å¤æçæ°æ®ç»æï¼5ç§ï¼
strings-->å³ç®åçkey-valueï¼å°±æ¯memcachedå¯ä»¥åå¨çå¯ä¸çä¸ç§å½¢å¼ï¼æ¥ä¸æ¥çåç§æ¯memcachedä¸è½ç´æ¥åå¨çåç§æ ¼å¼ï¼å½ç¶ç论ä¸å¯ä»¥å
å°ä¸é¢çä¸äºæ°æ®ç»æä¸çä¸è¥¿å°è£
æ对象ï¼ç¶ååå
¥memcachedï¼ä½æ¯ä¸æ¨èå°å¤§å¯¹è±¡åå
¥memcachedï¼å 为memcachedçåä¸valueçæ大åå¨ä¸º1Mï¼å¯è½å³ä½¿éç¨äºå缩ç®æ³ä¹ä¸å¤ï¼å³ä½¿å¤ï¼å¯è½ååçæçä¹ä¸é«ï¼èredisçvalueæ大为1Gï¼
hashs-->çåhashTable
lists-->çåLinkedList
sets-->çåhashSetï¼äºå®ä¸åºå±æ¯ä¸ä¸ªhashTable
sorted sets-->åºå±æ¯ä¸ä¸ªskipList
æ两ç§æ¹å¼å¯ä»¥å¯¹ç¼åæ°æ®è¿è¡æä¹
å
RDB
AOF
äºä»¶è°åº¦
åå¸è®¢é
ç
4ãéæç¼å
ä¸æspring cacheï¼spring cacheèªå·±ç»§æ¿äºehcacheä½ä¸ºäºç¼åçå®ç°ç±»ï¼æ们ä¹å¯ä»¥ä½¿ç¨guava cacheãmemcachedãredisèªå·±æ¥å®ç°spring cacheçåºå±ãå½ç¶ï¼spring cacheå¯ä»¥æ ¹æ®å®ç°ç±»æ¥å°ç¼ååå¨æ¬å°è¿æ¯åå¨è¿ç¨æºå¨ä¸ã
5ã页é¢ç¼å
å¨ä½¿ç¨jspçæ¶åï¼æ们ä¼å°ä¸äºå¤æç页é¢ä½¿ç¨Oscacheè¿è¡é¡µé¢ç¼åï¼ä½¿ç¨é常ç®åï¼å°±æ¯å 个æ ç¾çäºå¿ï¼ä½æ¯ï¼ç°å¨ä¸è¬çä¼ä¸ï¼åå°é½ä¼ä½¿ç¨velocityãfreemakerè¿ä¸¤ç§æ¨¡æ¿å¼æï¼æ¬èº«é度就已ç»å¾å¿«äºï¼é¡µé¢ç¼å使ç¨çä¹å°±å¾å°äºã
æ»ç»ï¼
å¨å®é
ç产ä¸ï¼æ们é常ä¼ä½¿ç¨guava cacheåæ¬å°ç¼å+redisååå¸å¼ç¼å+spring cacheå°±éæç¼åï¼åºå±ä½¿ç¨redisæ¥å®ç°ï¼çå½¢å¼
guava cache使ç¨å¨æ´å¿«çè·åç¼åæ°æ®ï¼åæ¶ç¼åçæ°æ®é并ä¸å¤§çæ
åµ
spring cacheéæç¼åæ¯ä¸ºäºç®å便æ·çå»ä½¿ç¨ç¼åï¼ä»¥æ³¨è§£çæ¹å¼å³å¯ï¼ï¼ä½¿ç¨redisåå
¶å®ç°ç±»æ¯ä¸ºäºå¯ä»¥åæ´å¤çæ°æ®å¨æºå¨ä¸
redisç¼ååç¬ä½¿ç¨æ¯ä¸ºäºå¼¥è¡¥spring cacheéæç¼åçä¸çµæ´»
å°±æ个人èè¨ï¼å¦æéè¦ä½¿ç¨åå¸å¼ç¼åï¼é£ä¹é¦å
redisæ¯å¿
éçï¼å 为å¨å®é
å¼åä¸ï¼æ们ä¼ç¼ååç§åæ ·çæ°æ®ç±»åï¼å¨ä½¿ç¨äºredisçåæ¶ï¼memcachedå°±å®å
¨å¯ä»¥èå¼äºï¼ä½æ¯ç°å¨è¿æå¾å¤å
¬å¸å¨åæ¶ä½¿ç¨memcachedåredis两ç§ç¼åã
温馨提示:答案为网友推荐,仅供参考