您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
workerman-redis组件-hExists
发布时间:2021-12-28 21:26:16编辑:雪饮阅读()
hExists
查看哈希表的指定字段是否存在。存在返回1,字段不存在或者key不存在返回0,发生错误返回false。
实例:
<?php
use Workerman\Worker;
use Workerman\Redis\Client;
use Workerman\Connection\TcpConnection;
use Workerman\Timer;
require_once __DIR__ . '/vendor/autoload.php';
$worker = new Worker('http://0.0.0.0:6161');
global $offset;
$worker->onWorkerStart = function() {
global $offset;
$offset=0;
};
$worker->onMessage = function(TcpConnection $connection, $data) {
$redis = new Client('redis://127.0.0.1:6379');
$redis->hExists('h', 'a', function ($result) {
var_dump($result); //
});
};
Worker::runAll();
实例运行并有http客户端访问:
[root@localhost workerman]# php index.php start
Workerman[index.php] start in DEBUG mode
----------------------------------------- WORKERMAN -----------------------------------------
Workerman version:4.0.26 PHP version:7.3.31
------------------------------------------ WORKERS ------------------------------------------
proto user worker listen processes status
tcp root none http://0.0.0.0:6161 1 [OK]
---------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
int(0)
关键字词:workerman,redis,hExists