Skip to content

Commit

Permalink
call-time pass by reference is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
toymachine committed Apr 2, 2010
1 parent 4a69422 commit e92021c
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README
Expand Up @@ -35,7 +35,7 @@ $batch->execute($connection);
$batch = $libredis->create_batch();
$batch->get('hello');
$batch->execute($connection);
while($batch->next_reply(&$reply_type, &$reply_value, &$reply_length)) {
while($batch->next_reply($reply_type, $reply_value, $reply_length)) {
echo $reply_value, PHP_EOL;
}

Expand Down
71 changes: 70 additions & 1 deletion TODO.TXT
Expand Up @@ -6,4 +6,73 @@

php:
- batch->simple_reply()
- use static redis lib for php extension
- use static redis lib for php extension
- Call-time pass-by-reference
Apr 2 16:38:40 src@web714 nginx: 2010/04/02 16:38:40 [error] 29536#0: *92778127 FastCGI sent in stderr: "PHP Warning: Call-time pass-by-reference has been deprecated in /var/www/hyves/CLASSES/UTIL/Application/HyvesApplication.php on line 15
- read/write timeout error


15:40:24.522793 write(8, "SET hellohenk 8\r\nblaataap\r\n"..., 27) = 27
15:40:24.522843 epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:40:24.522880 epoll_wait(3, {}, 32767, 0) = 0
15:40:24.522910 epoll_ctl(3, EPOLL_CTL_DEL, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:40:24.522943 close(8) = 0
15:40:24.522996 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 8
15:40:24.523035 fcntl(8, F_GETFL) = 0x2 (flags O_RDWR)
15:40:24.523064 fcntl(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
15:40:24.523091 connect(8, {sa_family=AF_INET, sin_port=htons(6379), sin_addr=inet_addr("10.13.5.3")}, 16) = -1 EINPROGRESS
(Operation now in progress)
15:40:24.523153 epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLOUT, {u32=8, u64=8}}) = 0
15:40:24.523186 epoll_wait(3, {{EPOLLOUT, {u32=8, u64=8}}}, 32767, 200) = 1
15:40:24.524197 epoll_ctl(3, EPOLL_CTL_DEL, 8, {EPOLLOUT, {u32=8, u64=8}}) = 0
15:40:24.524321 getsockopt(8, SOL_SOCKET, SO_ERROR, [17179869184], [4]) = 0
15:40:24.524418 epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:40:24.524515 write(8, "GET hellohenk\r\n"..., 15) = 15
15:40:24.524612 epoll_wait(3, {{EPOLLIN, {u32=8, u64=8}}}, 32767, 199) = 1
15:40:24.525609 epoll_ctl(3, EPOLL_CTL_DEL, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:40:24.525678 read(8, "$8\r\nblaataap\r\n"..., 12288) = 14


15:38:57.301544 write(8, "SET hellohenk 8\r\nblaataap\r\n"..., 27) = 27
15:38:57.301602 epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:38:57.301640 epoll_wait(3, {}, 32767, 0) = 0
15:38:57.301671 epoll_ctl(3, EPOLL_CTL_DEL, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:38:57.301706 close(8) = 0
15:38:57.301762 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 8
15:38:57.301806 fcntl(8, F_GETFL) = 0x2 (flags O_RDWR)
15:38:57.301836 fcntl(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
15:38:57.301865 connect(8, {sa_family=AF_INET, sin_port=htons(6379), sin_addr=inet_addr("10.13.5.3")}, 16) = -1 EINPROGRESS (Operation now in progress)
15:38:57.301942 epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLOUT, {u32=8, u64=8}}) = 0
15:38:57.301975 epoll_wait(3, {{EPOLLOUT, {u32=8, u64=8}}}, 32767, 200) = 1
15:38:57.302932 epoll_ctl(3, EPOLL_CTL_DEL, 8, {EPOLLOUT, {u32=8, u64=8}}) = 0
15:38:57.302968 getsockopt(8, SOL_SOCKET, SO_ERROR, [17179869184], [4]) = 0
15:38:57.303001 epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:38:57.303031 write(8, "GET hellohenk\r\n"..., 15) = 15
15:38:57.303072 epoll_wait(3, {{EPOLLIN, {u32=8, u64=8}}}, 32767, 199) = 1
15:38:57.304068 epoll_ctl(3, EPOLL_CTL_DEL, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
15:38:57.304113 read(8, "$8\r\nblaataap\r\n"..., 12288) = 14



write(9, "SET hellohenk 8\r\nblaataap\r\n", 27) = 27
epoll_ctl(3, EPOLL_CTL_ADD, 9, {EPOLLIN, {u32=11263872, u64=11263872}}) = 0
epoll_wait(3, {{EPOLLIN, {u32=11263872, u64=11263872}}}, 1023, 200) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 9, {EPOLLIN, {u32=11263872, u64=11263872}}) = 0
read(9, "+OK\r\n", 12288) = 5
write(9, "GET hellohenk\r\n", 15) = 15
epoll_ctl(3, EPOLL_CTL_ADD, 9, {EPOLLIN, {u32=11263872, u64=11263872}}) = 0
epoll_wait(3, {{EPOLLIN, {u32=11263872, u64=11263872}}}, 1023, 200) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 9, {EPOLLIN, {u32=11263872, u64=11263872}}) = 0
read(9, "$8\r\nblaataap\r\n", 12288) = 14


>...>...>...$libredis = Libredis();
>...>...>...$batch = $libredis->create_batch();
>...>...>...$batch->set('hellohenk', 'blaataap')->execute($libredis->get_connection("10.13.5.3"), 200);
>...>...>...$batch = $libredis->create_batch();
>...>...>...$batch->get('hellohenk')->execute($libredis->get_connection("10.13.5.3"), 200);
while($level = $batch->next_reply(&$reply_type, &$reply_value, &$reply_length)) {
>...>...>...>...openlog("libredis", LOG_NDELAY, LOG_LOCAL2);
>...>... >.>...syslog(LOG_DEBUG, "$reply_type $reply_value");
>...>...>...}

8 changes: 7 additions & 1 deletion php/ext/redis/php_redis.c
Expand Up @@ -329,13 +329,19 @@ PHP_METHOD(Batch, execute)
Executor_free(executor);
}

ZEND_BEGIN_ARG_INFO_EX(arginfo_batch_next_rely, 0, 0, 3)
ZEND_ARG_INFO(1, reply_type)
ZEND_ARG_INFO(1, reply_value)
ZEND_ARG_INFO(1, reply_length)
ZEND_END_ARG_INFO()

function_entry batch_methods[] = {
PHP_ME(Batch, __destruct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR)
PHP_ME(Batch, write, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Batch, set, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Batch, get, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Batch, execute, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Batch, next_reply, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Batch, next_reply, arginfo_batch_next_rely, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};

Expand Down
45 changes: 8 additions & 37 deletions test.php
Expand Up @@ -79,11 +79,11 @@ function mget($keys, $ketama) {
$results = array();
foreach($batches as $server_ordinal=>$batch) {
//read the single multibulk reply
$batch->next_reply(&$mb_reply_type, &$mb_reply_value, &$mb_reply_length);
$batch->next_reply($mb_reply_type, $mb_reply_value, $mb_reply_length);
if(RT_ERROR != $mb_reply_type) {
//read the individual bulk replies in the multibulk reply
foreach($batch_keys[$server_ordinal] as $key) {
$batch->next_reply(&$reply_type, &$reply_value, &$reply_length);
$batch->next_reply($reply_type, $reply_value, $reply_length);
if(RT_BULK == $reply_type) {
$results[$key] = $reply_value;
}
Expand All @@ -104,7 +104,7 @@ function test_mget()
$ketama->create_continuum();

//$N = 200000;
$N = 2000;
$N = 20000;
$M = 200;

$connection1 = $libredis->get_connection("$ip:6379");;
Expand Down Expand Up @@ -142,8 +142,9 @@ function test_simple() {
$executor = $libredis->create_executor();
$executor->add($connection, $batch);
$executor->execute(400);
$batch->next_reply(&$reply_type, &$reply_value, &$reply_length);
$batch->next_reply($reply_type, $reply_value, $reply_length);
print_r($reply_value);
echo gettype($reply_value), PHP_EOL;
}
}

Expand Down Expand Up @@ -175,7 +176,7 @@ function test_integer_reply()
$connection = $libredis->get_connection("$ip:6379");
$batch = $libredis->create_batch("INCR incr_test\r\n", 1);
$connection->execute($batch);
while($level = $batch->next_reply(&$reply_type, &$reply_value, &$reply_length)) {
while($level = $batch->next_reply($reply_type, $reply_value, $reply_length)) {
echo "start", PHP_EOL;
echo "\ttype ", $reply_type, PHP_EOL;
echo "\tval ", $reply_value, " (", gettype($reply_value), ")", PHP_EOL;
Expand Down Expand Up @@ -203,14 +204,14 @@ function test_convenience()
$batch->set("joop", "blaat");
$connection = $libredis->get_connection("$ip:6379");
$connection->execute($batch);
while($batch->next_reply(&$reply_type, &$reply_value, &$reply_length)) {
while($batch->next_reply($reply_type, $reply_value, $reply_length)) {
echo $reply_value, PHP_EOL;
}
$batch = $libredis->create_batch();
$batch->get("blaat");
$batch->get("joop");
$connection->execute($batch);
while($batch->next_reply(&$reply_type, &$reply_value, &$reply_length)) {
while($batch->next_reply($reply_type, $reply_value, $reply_length)) {
echo $reply_value, PHP_EOL;
}
}
Expand All @@ -225,34 +226,4 @@ function test_convenience()
//test_convenience();
//echo "done...!", PHP_EOL;

/*
$libredis = Libredis();
$connection = $libredis->get_connection("127.0.0.1");
//set a key
$batch = $libredis->create_batch();
$batch->set('hello', 'world');
$batch->execute($connection);
//now fetch the key
$batch = $libredis->create_batch();
$batch->get('hello');
$batch->execute($connection);
while($batch->next_reply(&$reply_type, &$reply_value, &$reply_length)) {
echo $reply_value, PHP_EOL;
}
*/

/*
$libredis = Libredis();
$connection1 = $libredis->get_connection("127.0.0.1:6973");
$connection2 = $libredis->get_connection("127.0.0.1:6980");
$batch1 = $libredis->create_batch();
$batch1->set('hello', 'world');
$batch2 = $libredis->create_batch();
$batch2->set('hello2', 'world2');
$executor = $libredis->create_executor();
$executor->add($connection1, $batch1);
$executor->add($connection2, $batch2);
$executor->execute(); // execute all batches against all connections in parallel.
*/

?>

0 comments on commit e92021c

Please sign in to comment.