sCard 命令/方法/函数

Returns the cardinality of the set identified by key.

返回SET容器的成员数


Parameters

key


Return value

LONG the cardinality of the set identified by key, 0 if the set doesn't exist.


Example

$redis->sAdd('key1' , 'member1');

$redis->sAdd('key1' , 'member2');

$redis->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/

$redis->sCard('key1'); /* 3 */

$redis->sCard('keyX'); /* 0 */