返回 key 所储存的字符串值的长度。

    1. <?php
    2. //连接本地的 Redis 服务
    3. $redis = new Redis();
    4. $redis->connect('10.1.3.15', 6379);
    5. $redis->auth('kuaicdn_redis_passwd');
    6. $redis->flushAll();
    7. $ret['exec'][]=$redis->set('list_test1','12345');
    8. $ret['exec'][]=$redis->set('list_test2','我是中国人');
    9. $ret['exec'][]=$redis->set('list_test3','12345我是中国人');
    10. $ret['ret'][]=$redis->strlen('list_test1');
    11. $ret['ret'][]=$redis->strlen('list_test2');
    12. $ret['ret'][]=$redis->strlen('list_test3');
    13. print_r($ret);
    14. ?>

    返回值:

    1. Array
    2. (
    3. [exec] => Array
    4. (
    5. [0] => 1
    6. [1] => 1
    7. [2] => 1
    8. )
    9. [ret] => Array
    10. (
    11. [0] => 5
    12. [1] => 15
    13. [2] => 20
    14. )
    15. )

    值得注意的是 一个中文占用了 5个字符串