###wiki wiki
###contact 更多疑问请+qq群 233415606 or website http://www.hnphper.com
This is a client written in C as a PHP module for ssdb.
###wiki wiki
###contact 更多疑问请+qq群 233415606 or website http://www.hnphper.com
现在执行命令
./configure --with-php-config=/usr/local/php/bin/php-config
make
出现问题
make: *** [ssdb_geo.lo] Error 1
不清楚什么情况,希望作者帮忙解答下,谢谢
重现代码:
<?php
$host = '127.0.0.1';
$port = 8888;
$ssdb = new SimpleSSDB($host, $port);
$ssdb->countbit('a', 0);
报错:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1366923971 bytes) in xxx/phpssdb/a.php on line 14
try {
$ssdb = new ssdb();
$ssdb->connect('192.168.1.1', 8888);
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}
常驻内存的程序,一般connect放一个放那,如果执行的时候发现链接断开就会,重新在链接一次. 但是这个库并没有提供在执行命令的时候 到底是不是链接断开的提示.
代码大概如下:
$xx = array(
'abc',
'abc',
'abc',
'abc',
);
$data = $db->multi_hset('test', $xx);
测试环境
mac 10.10
PHP 5.5.20
[1] 77119 segmentation fault php kk.php
Installing on PHP TS version always get error :
make && make install :
error /usr/include/php-zts/php/Zend/../TSRM/TSRM.h:167:18: error: 'tsrm_ls' undeclared (first use in this function).
好像取得空数据时,失败时,还有写入成功时,都反回NULL,这样比较难判断成功失败,
建议增加失败时的返回值
如题.
hset一个不存在的key时成功返回true
hset一个存在的key时成功总返回false
到底要如何界定操作成功还是失败?
/Users/yuyi/Code/tools/phpssdb/ssdb_library.c:21:10: fatal error: 'ext/standard/php_smart_str.h' file not found
#include "ext/standard/php_smart_str.h"
php7 已经变成php_smart_string
/bin/bash /opt/phpssdb/libtool --mode=compile cc -I. -I/opt/phpssdb -DPHP_ATOM_INC -I/opt/phpssdb/include -I/opt/phpssdb/main -I/opt/phpssdb -I/usr/local/swoole/include/php -I/usr/local/swoole/include/php/main -I/usr/local/swoole/include/php/TSRM -I/usr/local/swoole/include/php/Zend -I/usr/local/swoole/include/php/ext -I/usr/local/swoole/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /opt/phpssdb/ssdb_library.c -o ssdb_library.lo
cc -I. -I/opt/phpssdb -DPHP_ATOM_INC -I/opt/phpssdb/include -I/opt/phpssdb/main -I/opt/phpssdb -I/usr/local/swoole/include/php -I/usr/local/swoole/include/php/main -I/usr/local/swoole/include/php/TSRM -I/usr/local/swoole/include/php/Zend -I/usr/local/swoole/include/php/ext -I/usr/local/swoole/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /opt/phpssdb/ssdb_library.c -fPIC -DPIC -o .libs/ssdb_library.o
/opt/phpssdb/ssdb_library.c:21:40: fatal error: ext/standard/php_smart_str.h: 没有那个文件或目录
compilation terminated.
Makefile:193: recipe for target 'ssdb_library.lo' failed
make: *** [ssdb_library.lo] Error 1
fatal error: ext/standard/php_smart_str.h: 没有那个文件或目录
echo "hset" . PHP_EOL;
$result = $ssdb_handle->hset("blog_list", "1", "1");
var_dump($result);
$result = $ssdb_handle->hset("blog_list", "1", "2");
var_dump($result);
运行第一次
true
false
运行第二次
false
false
运行第三次
false
false
....
如题!
能不能贴出个和SimpleSSDB php客户端的性能对比?
看看用C是不是有实质的提升
Affected php versions (I've checked, maybe more): 7.0.4 , 7.0.5 , 7.0.6 (current)
$keys = array_map(function($key) { return md5('A') . md5($key); }, range(1, 20));
$ssdb = new SSDB ();
$ssdb->connect("127.0.0.1", 8888);
$ssdb->option(SSDB ::OPT_SERIALIZER, SSDB::SERIALIZER_PHP);
foreach ($keys as $key) {
$ssdb->set($key, $key);
}
$result = $ssdb->multi_get($keys); // Segmentation fault (core dumped)
var_dump($result);
Bug fails only in case SSDB ::OPT_SERIALIZER is set to SSDB::SERIALIZER_PHP
Here's a sample of $ssdb->info() output
$ssdb = new SSDB();
$ssdb->connect('127.0.0.1', 8888, 1);
var_dump($ssdb->info());
array(9) {
["version"]=>
string(5) "1.9.3"
["links"]=>
string(1) "2"
["total_calls"]=>
string(2) "10"
["dbsize"]=>
string(10) "1435004734"
["binlogs"]=>
string(70) " capacity : 20000000
min_seq : 4196359
max_seq : 11380832"
["replication"]=>
string(183) "slaveof arbitr.internal:8888
id : arbitr
type : mirror
status : SYNC
last_seq : 4260722
copy_count : 0
sync_count : 0"
["serv_key_range"]=>
string(71) " kv : "" - ""
hash: "" - ""
zset: "" - ""
list: "" - """
["data_key_range"]=>
string(137) " kv : "aa" - "zz"
hash: "" - ""
zset: "" - ""
list: "" - """
["leveldb.stats"]=>
string(298) " Compactions
Level Files Size(MB) Time(sec) Read(MB) Write(MB)
--------------------------------------------------
0 0 0 1 0 19
1 7 155 6 150 150
2 47 1451 0 0 0
"
}
But the real output of ./ssdb-cli contains multiple "replication" sections
version
1.9.3
links
1
total_calls
8
dbsize
1435004734
binlogs
capacity : 20000000
min_seq : 4196359
max_seq : 11380832
replication
client 172.30.1.1:49044
type : mirror
status : COPY
last_seq : 11380832
replication
client 172.30.1.2:55022
type : mirror
status : COPY
last_seq : 11380832
replication
client 172.30.1.3:55484
type : mirror
status : SYNC
last_seq : 11380832
replication
client 172.30.1.4:52716
type : mirror
status : SYNC
last_seq : 11380832
replication
slaveof node-0.ssdb.intenal:8888
id : node0
type : mirror
status : SYNC
last_seq : 12302239
copy_count : 0
sync_count : 0
replication
slaveof node-1.ssdb.internal:8888
id : node1
type : mirror
status : INIT
last_seq : 3845251
copy_count : 0
sync_count : 0
replication
slaveof node-2.ssdb.internal:8888
id : node2
type : mirror
status : SYNC
last_seq : 11380832
copy_count : 0
sync_count : 0
replication
slaveof arbitr.internal:8888
id : arbitr
type : mirror
status : SYNC
last_seq : 4260722
copy_count : 0
sync_count : 0
serv_key_range
kv : "" - ""
hash: "" - ""
zset: "" - ""
list: "" - ""
data_key_range
kv : "aa" - "zz"
hash: "" - ""
zset: "" - ""
list: "" - ""
leveldb.stats
Compactions
Level Files Size(MB) Time(sec) Read(MB) Write(MB)
--------------------------------------------------
0 0 0 1 0 19
1 7 155 6 150 150
2 47 1451 0 0 0
Bug in ssdb_map_response: https://github.com/jonnywang/phpssdb/blob/f2421da55dbfcf19fd0c1f89716820fd74b0c4c3/ssdb_library.c#L910
I suppose the best option will be duplicate ssdb_map_response function specially for info data. because this structure is unique.
Using hgetall will truncate values containing binary encoding presumably due to line break detection bug. When requesting using standard hget($key,'r') the bug does not occur.
$ssdb_simple = new SimpleSSDB('10.0.0.1',8888); // Native PHP class
$redis = new Redis();// Redis C extension
$ssdb = new SSDB();// phpssdb C extension
$ssdb->connect('10.0.0.1', 8888);
$redis->connect('10.0.0.1', 8888);
$response = $ssdb->hgetall($key);
print_r($response);
$response = $ssdb_simple->hgetall($key);
print_r($response);
$response = $redis->hgetall($key);
print_r($response);
Produces
Array
(
[r] => ??? alt2.gmail-smtp-in.l.google.com?!
[s] =>
)
Array
(
[r] => ??? alt2.gmail-smtp-in.l.google.com?!3~!4j!? z^1j=
[s] => A
)
Array
(
[r] => ??? alt2.gmail-smtp-in.l.google.com?!3~!4j!? z^1j=
[s] => A
)
/usr/local/src/phpssdb/ssdb_class.c: 在函数‘register_ssdb_class’中:
/usr/local/src/phpssdb/ssdb_class.c:3687:2: 错误:提供给函数‘zend_register_class_alias_ex’的实参太少
zend_register_class_alias_ex(ZEND_STRL("SimpleSSDB"), ssdb_ce TSRMLS_CC);
^
In file included from /usr/local/include/php/main/php.h:37:0,
from /usr/local/src/phpssdb/ssdb_class.c:19:
/usr/local/include/php/Zend/zend_API.h:287:14: 附注:在此声明
ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, int persistent);
^
make: *** [ssdb_class.lo] 错误 1
/root/phpssdb/ssdb.c:42: error: ‘PHP_FE_END’ undeclared here (not in a function)
make: *** [ssdb.lo] Error 1
ssdb_library.c:93:3: error: use of undeclared identifier 'tsrm_ls' php_stream_close(ssdb_sock->stream);
nclude/php/main/php_streams.h:283:83: note: expanded from macro 'php_stream_close'
scan的limit不能使用-1 也就是返回全部数据
使用的php7版本
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.