sAdd

PHP Redis

sAdd

Description

Adds a value to the set value stored at key. If this value is already in the set, FALSE is returned.

添加一个VALUE到SET容器中,如果这个VALUE已经存在于SET中,那么返回FLASE。

Parameters

key value

Return value

BOOL TRUE if value didn't exist and was added successfully, FALSE if the value is already present.

如果VALUE不存在于SET中,那么ADDED成功,返回TRUE,负责返回FALSE。

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