<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] > [github](https://github.com/eko/gocache) ## 概述 - 多個緩存存儲:實際上在內存,Redis或您自己的自定義存儲中 - 鏈式緩存:以優先級順序使用多個緩存(例如,內存然后回退到Redis共享緩存) - 可加載的緩存:允許您調用回調函數以將數據放回緩存 - 指標緩存,用于存儲有關緩存使用情況的指標(命中,未命中,設置成功,設置錯誤等) - 封送處理程序可自動封送/解組緩存值作為結構 - 在商店中定義默認值,并在設置數據時覆蓋它們 - 通過到期時間和/或使用標簽來使緩存無效 ### 內置緩存 * [Memory (bigcache)](https://github.com/allegro/bigcache)(allegro/bigcache) * [Memory (ristretto)](https://github.com/dgraph-io/ristretto)(dgraph-io/ristretto) * [Memcache](https://github.com/bradfitz/gomemcache)(bradfitz/memcache) * [Redis](https://github.com/go-redis/redis/v7)(go-redis/redis) * More to come soon ## 例子 ### memched ``` memcacheStore := store.NewMemcache( memcache.New("10.0.0.1:11211", "10.0.0.2:11211", "10.0.0.3:11212"), &store.Options{ Expiration: 10*time.Second, }, ) cacheManager := cache.New(memcacheStore) err := cacheManager.Set("my-key", []byte("my-value"), &cache.Options{ Expiration: 15*time.Second, // Override default value of 10 seconds defined in the store }) if err != nil { panic(err) } value := cacheManager.Get("my-key") cacheManager.Delete("my-key") cacheManager.Clear() // Clears the entire cache, in case you want to flush all cache ``` ### Memory (using Bigcache) ``` bigcacheClient, _ := bigcache.NewBigCache(bigcache.DefaultConfig(5 * time.Minute)) bigcacheStore := store.NewBigcache(bigcacheClient, nil) // No otions provided (as second argument) cacheManager := cache.New(bigcacheStore) err := cacheManager.Set("my-key", "my-value", nil) if err != nil { panic(err) } value := cacheManager.Get("my-key") ``` ### Memory (using Ristretto) ``` ristrettoCache, err := ristretto.NewCache(&ristretto.Config{ NumCounters: 1000, MaxCost: 100, BufferItems: 64, }) if err != nil { panic(err) } ristrettoStore := store.NewRistretto(ristrettoCache, nil) cacheManager := cache.New(ristrettoStore) err := cacheManager.Set("my-key", "my-value", &cache.Options{Cost: 2}) if err != nil { panic(err) } value := cacheManager.Get("my-key") cacheManager.Delete("my-key") ``` ### Redis ``` redisStore := store.NewRedis(redis.NewClient(&redis.Options{ Addr: "127.0.0.1:6379", }), nil) cacheManager := cache.New(redisStore) err := cacheManager.Set("my-key", "my-value", &cache.Options{Expiration: 15*time.Second}) if err != nil { panic(err) } value := cacheManager.Get("my-key") ```
                  <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>

                              哎呀哎呀视频在线观看