<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 11. Caching 緩存 # 11. Caching 緩存 Shiro 開發團隊明白在許多應用程序中性能是至關重要的。Caching 是從第一天開始第一個建立在 Shiro 中的一流功能,以確保安全操作保持盡可能的快。 然而,Caching 作為一個概念是 Shiro 的基本組成部分,實現一個完整的緩存機制是安全框架核心能力之外的事情。為此,Shiro 的緩存支持基本上是一個抽象的(包裝)API,它將“坐”在一個基本的緩存機制產品(例如,Ehcache,OSCache,Terracotta,Coherence,GigaSpaces,JBossCache 等)之上。這允許Shiro 終端用戶配置他們喜歡的任何緩存機制。 ## Caching API Shiro 有三個重要的緩存接口: - [CacheManager](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/cache/CacheManager.html) - 負責所有緩存的主要管理組件,它返回 Cache 實例。 - [Cache](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/cache/Cache.html) - 維護key/value 對。 - [CacheManagerAware](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/cache/CacheManagerAware.html) - 通過想要接收和使用 CacheManager 實例的組件來實現。 CacheManager 返回Cache 實例,各種不同的Shiro 組件使用這些Cache 實例來緩存必要的數據。任何實現了 CacheManagerAware 的 Shiro 組件將會自動地接收一個配置好的 CacheManager,該 CacheManager 能夠用來獲取 Cache 實例。 Shiro 的 [SecurityManager](http://shiro.apache.org/securitymanager.html) 實現及所有 [AuthorizingRealm](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/realm/AuthenticatingRealm.html) 實現都實現了 CacheManagerAware 。如果你在 SecurityManager 上設置了 CacheManger,它反過來也會將它設置到實現了CacheManagerAware 的各種不同的 Realm 上(OO delegation)。例如,在 shiro.ini 中: ``` securityManager.realms = $myRealm1, $myRealm2, ..., $myRealmN ... cacheManager = my.implementation.of.CacheManager ... securityManager.cacheManager = $cacheManager # at this point, the securityManager and all CacheManagerAware # realms have been set with the cacheManager instance ``` ## CacheManager Implementations Shiro提供了許多開箱即用 CacheManager 實現,你可能會發現有用的而不是執行你自己的。 ### MemoryConstrainedCacheManager [MemoryConstrainedCacheManager](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/cache/MemoryConstrainedCacheManager.html) 是一個 緩存管理器 實現適合單個jvm 生產環境。 這不是集中/分布式,所以,如果你的應用程序跨越多個 JVM(例如 web 應用程序運行在多個 web 服務器),你想要緩存實體跨 JVM 訪問,您將需要使用一個分布式緩存實現。 MemoryConstrainedCacheManager 管理 [MapCache](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/cache/MapCache.html) 情況下,一個 MapCache 每個命名的緩存實例。 每一個 MapCache Shiro 的實例支持 SoftHashMap 它可以自動調整大小本身基于應用程序的運行時內存約束/需求(通過利用 JDK 嗎 softreference 實例)。 因為 MemoryConstrainedCacheManager 可以根據應用程序的內存配置文件自動調整大小本身,它的使用是安全的,在單個 jvm 的生產應用程序以及測試的需要。 然而,它沒有更多的高級功能 suche 生存時間或 Time-to-Expire 設置緩存實體。 對于這些更先進的緩存管理功能,您可能會希望使用下面更先進的緩存管理器產品。 ``` ... cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager ... securityManager.cacheManager = $cacheManager ``` ### HazelcastCacheManager *Shiro 1.3 or later* *這個特性在當前版本中還沒有發布。 Shiro 1.3 以后將會出現* 待定。 ### EhCacheManager 待定。 ## Authorization Cache Invalidation 授權緩存失效 最后請注意, [AuthorizingRealm](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/realm/AuthorizingRealm.html) 有一個 [clearCachedAuthorizationInfo](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/realm/AuthorizingRealm.html#clearCachedAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection)) 方法能夠被子類調用,用來清除特殊賬戶緩存的授權信息。它通常被自定義邏輯調用,如果與之匹配的賬戶授權數據發生了改變(來確保下次的授權檢查能夠捕獲新數據)。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看