spring的Cache註解和redis的區別

2021-10-22 19:26:37 字數 402 閱讀 3819

(1)不支援ttl,即不能設定過期時間 expires time,springcache 認為這是各個cache實現自己去完成的事情,有方案但是只能設定統一的過期時間,明顯不夠靈活。

(2)內部呼叫,非 public 方法上使用註解,會導致快取無效。內部呼叫方法的時候不會呼叫cache方法。

由於 springcache 是基於 spring aop 的動態**實現,由於**本身的問題,當同乙個類中呼叫另乙個方法,會導致另乙個方法的快取不能使用,這個在編碼上需要注意,避免在同乙個類中這樣呼叫。如果非要這樣做,可以通過再次**呼叫,如 ((category)aopcontext.currentproxy()).get(category) 這樣避免快取無效。

(3)key的問題。在清除快取的時候,無法指定多個快取塊,同時清除多個快取的key。

Spring 框架 spring註解的引入和使用

xmlns context spring context.xsd 必須 註解配置引入 該配置隱式引入了spring註解處理器bean autowiredannotationbeanpostprocessor 自動裝配 commonannotationbeanpostprocessor 共同註解 re...

Spring註解方式和註解小結

用於建立物件的4種註解方法 component 註解 beans xmlns xmlns xsi xmlns context xsi schemalocation spring beans.xsd spring context.xsd 在其實現類上新增註解 component userservice...

spring快取cache的使用

在spring配置檔案中新增schema和spring對快取註解的支援 xmlns xmlns aop xmlns xsi xmlns mvc xmlns context xmlns tx xmlns p xmlns cache xsi schemalocation spring beans 3.0...