1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        redisun為不同數(shù)據(jù)類型封裝統(tǒng)一的命令

        聯(lián)合創(chuàng)作 · 2023-09-30 23:33

        使用redis+lua為不同數(shù)據(jù)類型封裝統(tǒng)一的命令,降低redis操作的復(fù)雜度,提高性能。

        例如,創(chuàng)建一個key,常見的5種數(shù)據(jù)類型:string, hash, list, set, zset,均可使用同一個命令來實現(xiàn)

        <?php
        
        $key = 'hello-redisun';
        // string
        $value = 'hello';
        // list
        $value = [1,2,3];
        // set
        $value = ['hello', 'world', '!'];
        // zset
        $value = [
            'apple' => 1,
            'banana' => 2,
            'grape' => 3,
        ];
        // hash
        $value = [
            'name' => 'maria',
            'age' => 22,
        ];
        
        $ttl = 100;   // 100s后過期
        $ttl = null;  // 不過期,默認(rèn)值
        
        $model->create($key, $value, $ttl);

        已封裝的命令如下。所有的“set”類命令都支持設(shè)置ttl,如果不傳ttl參數(shù)或傳參為null,會保留key的當(dāng)前ttl。

        • create: 創(chuàng)建key

        • createNotExists: 當(dāng)key不存在時創(chuàng)建

        • createExists: 當(dāng)key存在時創(chuàng)建

        • insert: 創(chuàng)建key,支持批量創(chuàng)建

        • insertNotExists: key不存在時創(chuàng)建

        • insertExists: key存在時創(chuàng)建

        • get: 獲取key,支持批量獲取

        • getAndSet: 獲取key并設(shè)置新值

        • find: 獲取單個key

        • findBatch: 獲取多個key

        • update: 更新多個key

        • destroy: 刪除單個key

        • destroyBatch: 刪除多個key

        • delete: 刪除多個key

        瀏覽 18
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            午夜爽爽视频 | 黄片无码免费看 | 超碰天天搞 | 放荡护士夹得我好爽狂欲 | 亚洲免费中文字幕 | 337p粉嫩大胆色噜噜噜噜在线播放 | 福利在线看| 青青欧美| 宝贝~不许穿内裤调教 | 操老女人骚逼 |