返回 key 所储存的字符串值的长度。
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('10.1.3.15', 6379);
$redis->auth('kuaicdn_redis_passwd');
$redis->flushAll();
$ret['exec'][]=$redis->set('list_test1','12345');
$ret['exec'][]=$redis->set('list_test2','我是中国人');
$ret['exec'][]=$redis->set('list_test3','12345我是中国人');
$ret['ret'][]=$redis->strlen('list_test1');
$ret['ret'][]=$redis->strlen('list_test2');
$ret['ret'][]=$redis->strlen('list_test3');
print_r($ret);
?>
返回值:
Array
(
[exec] => Array
(
[0] => 1
[1] => 1
[2] => 1
)
[ret] => Array
(
[0] => 5
[1] => 15
[2] => 20
)
)
值得注意的是 一个中文占用了 5个字符串