1 Star 1 Fork 0

Paul/PHP_Redis

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
5_4_set.php 580 Bytes
Copy Edit Raw Blame History
Paul authored 7 years ago . 更新代码
<?php
/**
* set 类型操作
*/
// 连接redis
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
// 先删除对应的key
$redis->delete('set1');
// 设置set集合的值
$redis->sAdd('set1', 'val1');
$redis->sAdd('set1', 'val2');
$redis->sAdd('set1', 'val3');
$redis->sAdd('set1', 'val3');
// 获取set集合中的数量
$number = $redis->sCard('set1');
var_dump($number);
// 获取set集合中的所有值
$val = $redis->sMembers('set1');
var_dump($val);
/**
运行:
int(3)
array(3) {
[0]=>
string(4) "val1"
[1]=>
string(4) "val2"
[2]=>
string(4) "val3"
}
*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/paultest/PHP_Redis.git
git@gitee.com:paultest/PHP_Redis.git
paultest
PHP_Redis
PHP_Redis
master

Search