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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ### egg-redis 文檔:https://www.npmjs.com/package/egg-redis 安裝:npm?i?egg-redis?--save 開啟插件: ``` Change ${app_root}/config/plugin.js to enable redis plugin: exports.redis = { enable: true, package: 'egg-redis', }; ``` 設置redis連接 ``` Configure redis information in ${app_root}/config/config.default.js: Single Client config.redis = { client: { port: 6379, // Redis port host: '127.0.0.1', // Redis host password: 'auth', db: 0, }, } ``` ***** ### 封裝常用redis操作類 * [ ] service / cache.js ``` 'use strict'; const Service = require('egg').Service; class CacheService extends Service { /** * 設置 redis 緩存 * @param { String } key 鍵 * @param {String | Object | array} value 值 * @param { Number } expir 過期時間 單位秒 * @return { String } 返回成功字符串OK */ async set(key,value,expir=0) { const { redis } = this.app if (expir === 0) { return await redis.set(key, JSON.stringify(value)) } else { return await redis.set(key, JSON.stringify(value), 'EX', expir) } } /** * 獲取 redis 緩存 * @param { String } key 鍵 * @return { String | array | Object } 返回獲取的數據 */ async get(key) { const { redis } = this.app const result = await redis.get(key) return JSON.parse(result) } /** * redis 自增 * @param { String } key 鍵 * @param { Number } value 自增的值 * @return { Number } 返回遞增值 */ async incr(key, number=1) { const { redis } = this.app if (number === 1) { return await redis.incr(key) } else { return await redis.incrby(key, number) } } /** * 查詢長度 * @param { String } key * @return { Number } 返回數據長度 */ async strlen(key) { const { redis } = this.app return await redis.strlen(key) } } module.exports = CacheService; ```
                  <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>

                              哎呀哎呀视频在线观看