Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检查Aerospike数据库中是否存在密钥_Php_Aerospike - Fatal编程技术网

Php 检查Aerospike数据库中是否存在密钥

Php 检查Aerospike数据库中是否存在密钥,php,aerospike,Php,Aerospike,请您解释一下为什么Aerospike::exists方法抛出致命错误: $aerospike = new Aerospike( [ 'hosts' => [ ['addr' => '127.0.0.1', 'port' => 3000] ], 'shm' => [], ], false, [] ); $bins = ['value' => 99]; $akey

请您解释一下为什么
Aerospike::exists
方法抛出致命错误

$aerospike = new Aerospike(
    [
        'hosts' => [
            ['addr' => '127.0.0.1', 'port' => 3000]
        ],
        'shm' => [],
    ],
    false,
    []
);

$bins = ['value' => 99];
$akey = $aerospike->initKey('test', 'cache', 'test-data');

$putStatus = $aerospike->put(
    $akey,
    $bins,
    0,
    [Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND]
);
var_dump($putStatus); // Aerospike::OK here

$deleteStatus = $aerospike->remove($akey);
var_dump($deleteStatus); // Aerospike::OK here

$existsStatus = $aerospike->exists($akey, $metadata); // Fatal error
$ php aerospike.php
/tmp/aerospike.php:24:
int(0)
/tmp/aerospike.php:27:
int(0)
PHP Fatal error:  Aerospike::exists(): exists/getMetadata: 
    unable to fetch the record in /tmp/aerospike.php on line 29
PHP Stack trace:
PHP   1. {main}() /tmp/aerospike.php:0
PHP   2. Aerospike->exists() /tmp/aerospike.php:29
代码

$aerospike = new Aerospike(
    [
        'hosts' => [
            ['addr' => '127.0.0.1', 'port' => 3000]
        ],
        'shm' => [],
    ],
    false,
    []
);

$bins = ['value' => 99];
$akey = $aerospike->initKey('test', 'cache', 'test-data');

$putStatus = $aerospike->put(
    $akey,
    $bins,
    0,
    [Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND]
);
var_dump($putStatus); // Aerospike::OK here

$deleteStatus = $aerospike->remove($akey);
var_dump($deleteStatus); // Aerospike::OK here

$existsStatus = $aerospike->exists($akey, $metadata); // Fatal error
$ php aerospike.php
/tmp/aerospike.php:24:
int(0)
/tmp/aerospike.php:27:
int(0)
PHP Fatal error:  Aerospike::exists(): exists/getMetadata: 
    unable to fetch the record in /tmp/aerospike.php on line 29
PHP Stack trace:
PHP   1. {main}() /tmp/aerospike.php:0
PHP   2. Aerospike->exists() /tmp/aerospike.php:29
环境

$aerospike = new Aerospike(
    [
        'hosts' => [
            ['addr' => '127.0.0.1', 'port' => 3000]
        ],
        'shm' => [],
    ],
    false,
    []
);

$bins = ['value' => 99];
$akey = $aerospike->initKey('test', 'cache', 'test-data');

$putStatus = $aerospike->put(
    $akey,
    $bins,
    0,
    [Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND]
);
var_dump($putStatus); // Aerospike::OK here

$deleteStatus = $aerospike->remove($akey);
var_dump($deleteStatus); // Aerospike::OK here

$existsStatus = $aerospike->exists($akey, $metadata); // Fatal error
$ php aerospike.php
/tmp/aerospike.php:24:
int(0)
/tmp/aerospike.php:27:
int(0)
PHP Fatal error:  Aerospike::exists(): exists/getMetadata: 
    unable to fetch the record in /tmp/aerospike.php on line 29
PHP Stack trace:
PHP   1. {main}() /tmp/aerospike.php:0
PHP   2. Aerospike->exists() /tmp/aerospike.php:29
  • Ubuntu 16.04.1
  • PHP7.0.13
  • Arocient 3.4.13
  • Aerospike Docker镜像(服务器):
    Aerospike:3.10.1
测试

$aerospike = new Aerospike(
    [
        'hosts' => [
            ['addr' => '127.0.0.1', 'port' => 3000]
        ],
        'shm' => [],
    ],
    false,
    []
);

$bins = ['value' => 99];
$akey = $aerospike->initKey('test', 'cache', 'test-data');

$putStatus = $aerospike->put(
    $akey,
    $bins,
    0,
    [Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND]
);
var_dump($putStatus); // Aerospike::OK here

$deleteStatus = $aerospike->remove($akey);
var_dump($deleteStatus); // Aerospike::OK here

$existsStatus = $aerospike->exists($akey, $metadata); // Fatal error
$ php aerospike.php
/tmp/aerospike.php:24:
int(0)
/tmp/aerospike.php:27:
int(0)
PHP Fatal error:  Aerospike::exists(): exists/getMetadata: 
    unable to fetch the record in /tmp/aerospike.php on line 29
PHP Stack trace:
PHP   1. {main}() /tmp/aerospike.php:0
PHP   2. Aerospike->exists() /tmp/aerospike.php:29
我发现:

以及:

我检查了一下,但没有发现如何解决这个问题的线索


感谢

通过使用以下标志编译php客户端修复了此问题:

CFLAGS="-std=gnu99 -g -D__AEROSPIKE_PHP_CLIENT_LOG_LEVEL__=PHP_EXT_AS_LOG_LEVEL_OFF"