我是airospike的新手,我几乎没有问题,有些事情我从文档中无法理解。
我尝试在aerospike上做一些类似的事情(请看下面的例子),但我不确定它是否是正确的方式:
Redis客户:
$cache_key = "some.cache_key.1111";
$multi->zAdd($cache_key,534,"39e9a447af489f97d5047ba5aa304ec7");
Redis命令:
ZRANGE some.cache_key.1111 0 -1 withscores
133683) "39e9a447af489f97d5047ba5aa304ec7"
133684) "534"
and so on..
如何使aerospike数据库包含类似redis $cache_key = "some.cache_key.1111";
的类似结构,数字1111
可能会不时更改,但数据(键/值)不同?
如何遍历垃圾箱中的所有键/值?
```
$key = $db->initKey('test','votes','pk');
$bins = [ 'my_bin'=> ['6d69f5c66fb77c561059600f24664669' => 2222 ]];
$status = $db->put($key, $bins);
if ($status !== Aerospike::OK) {
var_dump($status, $db->error());
}
$key = $db->initKey('test','votes','pk');
$bins = [ 'another_bin'=> ['6d69f5c66fb77c561059600f2466466a' => 333 ]];
$status = $db->put($key, $bins);
if ($status !== Aerospike::OK) {
var_dump($status, $db->error());
exit(1);
}
$status = $db->get($key, $record);
var_dump($record);
```
输出:
array(3) {
'key' =>
array(4) {
'ns' =>
string(4) "test"
'set' =>
string(15) "votes"
'key' =>
NULL
'digest' =>
string(20) "����4�)q\�\000 ꤑ>��"
}
'metadata' =>
array(2) {
'ttl' =>
int(2592000)
'generation' =>
int(28)
}
'bins' =>
array(2) {
'my_bin' =>
array(1) {
'6d69f5c66fb77c561059600f24664669' =>
int(2222)
}
'another_bin' =>
array(1) {
'6d69f5c66fb77c561059600f2466466a' =>
int(333)
}
}
}
}
由于
答案 0 :(得分:2)
Aerospike通过SortedMap数据类型支持ZLIST类型的操作。但是,PHP客户端尚未完全实现地图或列表API。
查看Python客户端map functions的实现。