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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 緩存模塊 beego 的 cache 模塊是用來做數據緩存的,設計思路來自于 `database/sql`,目前支持 file、memcache、memory 和 redis 四種引擎,安裝方式如下: go get github.com/astaxie/beego/cache >如果你使用memcache 或者 redis 驅動就需要手工安裝引入包 go get -u github.com/astaxie/beego/cache/memcache >而且需要在使用的地方引入包 import _ "github.com/astaxie/beego/cache/memcache" ## 使用入門 首先引入包: import ( "github.com/astaxie/beego/cache" ) 然后初始化一個全局變量對象: bm, err := cache.NewCache("memory", `{"interval":60}`) 然后我們就可以使用bm增刪改緩存: bm.Put("astaxie", 1, 10*time.Second) bm.Get("astaxie") bm.IsExist("astaxie") bm.Delete("astaxie") ## 引擎設置 目前支持四種不同的引擎,接下來分別介紹這四種引擎如何設置: - memory 配置信息如下所示,配置的信息表示 GC 的時間,表示每個 60s 會進行一次過期清理: {"interval":60} - file 配置信息如下所示,配置 `CachePath` 表示緩存的文件目錄,`FileSuffix` 表示文件后綴,`DirectoryLevel` 表示目錄層級,`EmbedExpiry` 表示過期設置 {"CachePath":"./cache","FileSuffix":".cache","DirectoryLevel":"2","EmbedExpiry":"120"} - redis 配置信息如下所示,redis 采用了庫 [redigo](https://github.com/garyburd/redigo/tree/master/redis): {"key":"collectionName","conn":":6039","dbNum":"0","password":"thePassWord"} * key: Redis collection 的名稱 * conn: Redis 連接信息 * dbNum: 連接 Redis 時的 DB 編號. 默認是0. * password: 用于連接有密碼的 Redis 服務器. - memcache 配置信息如下所示,memcache 采用了 [vitess的庫](https://github.com/youtube/vitess/tree/master/go/memcache),表示 memcache 的連接地址: {"conn":"127.0.0.1:11211"} ## 開發自己的引擎 cache 模塊采用了接口的方式實現,因此用戶可以很方便的實現接口,然后注冊就可以實現自己的 Cache 引擎: type Cache interface { Get(key string) interface{} GetMulti(keys []string) []interface{} Put(key string, val interface{}, timeout time.Duration) error Delete(key string) error Incr(key string) error Decr(key string) error IsExist(key string) bool ClearAll() error StartAndGC(config string) error } 用戶開發完畢在最后寫類似這樣的: func init() { Register("myowncache", NewOwnCache()) }
                  <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>

                              哎呀哎呀视频在线观看