Files
addons
app_download_files
extend
hyhproject
mobile
oss
static
thinkphp
upload
vendor
5ini99
composer
oss-sdk
swoole
.github
benchmark
examples
async
atomic
channel
client
coroutine
eof
event
http
http2
ipv6
length
lock
memory
mmap
multicast
mysql
namespace
php
postgresql
process
redis
runtime
server
socket_coro
ssl
table
array.php
iterator.php
server.php
set.php
simulation.php
task
timer
udp
unixsock
websocket
buffer.php
c10k.php
channel.php
client2.php
db_pool.php
get_local_ip.php
hot_update_class.php
multi_port_server.php
mysql_proxy_server.php
proxy_sync.php
recv_1m_client.php
recv_file.php
redis_pool.php
reflection_test.php
ringqueue.php
send_1m_svr.php
sendfile_server.php
serialize.php
serialize2.php
server.c
server.php
server_hot_update_opcache.php
set_cpu_affinity.php
swoole_http_client.php
test.jpg
test_buffer.php
test_server.c
version.php
weather_server.php
include
src
tests
thirdparty
tools
travis
.gitignore
.gitmodules
.travis.yml
CMakeLists.txt
CREDITS
LICENSE
README.md
Version2.md
build.sh
clear.sh
config.m4
make.sh
package.xml
php7_wrapper.h
php_swoole.h
swoole.c
swoole_async.c
swoole_atomic.c
swoole_buffer.c
swoole_channel.c
swoole_channel_coro.cc
swoole_client.c
swoole_client_coro.c
swoole_config.h
swoole_coroutine.cc
swoole_coroutine.h
swoole_coroutine_util.c
swoole_event.c
swoole_http.h
swoole_http_client.c
swoole_http_client.h
swoole_http_client_coro.c
swoole_http_server.c
swoole_http_v2_client.c
swoole_http_v2_client.h
swoole_http_v2_client_coro.c
swoole_http_v2_server.c
swoole_lock.c
swoole_memory_pool.c
swoole_mmap.c
swoole_msgqueue.c
swoole_mysql.c
swoole_mysql.h
swoole_mysql_coro.c
swoole_postgresql_coro.c
swoole_postgresql_coro.h
swoole_process.c
swoole_process_pool.c
swoole_redis.c
swoole_redis_coro.c
swoole_redis_server.c
swoole_ringqueue.c
swoole_runtime.cc
swoole_serialize.c
swoole_serialize.h
swoole_server.c
swoole_server_port.c
swoole_socket_coro.c
swoole_table.c
swoole_timer.c
swoole_trace.c
swoole_websocket_server.c
wechat
.htaccess
autoload.php
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5B854518.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_startup.php
get_version.php
get_version_new.php
hyhproject.tar.gz
index.html
index.php
reg.lock
robots.txt
qlg.tsgz.moe/vendor/swoole/examples/table/set.php
2019-09-06 23:53:10 +08:00

48 lines
1.6 KiB
PHP
Executable File

<?php
$table = new swoole_table(1024);
$table->column('id', swoole_table::TYPE_INT, 4); //1,2,4,8
$table->column('name', swoole_table::TYPE_STRING, 64);
$table->column('num', swoole_table::TYPE_FLOAT);
$table->create();
//$worker = new swoole_process('child1', false, false);
//$worker->start();
//
//child
function child1($worker)
{
global $table;
$s = microtime(true);
$table->set('tianfenghan@qq.com', array('id' => 145, 'name' => 'rango', 'num' => 3.1415));
$table->set('350749960@qq.com', array('id' => 358, 'name' => "Rango1234", 'num' => 3.1415));
$table->set('hello@qq.com', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415));
$table->set('tianfenghan@qq.com', array('id' => 145, 'name' => 'rango', 'num' => 3.1415));
$table->set('350749960@qq.com', array('id' => 358, 'name' => "Rango1234", 'num' => 3.1415));
echo "set - 5 use: ".((microtime(true) - $s) * 1000)."ms\n";
}
//master
sleep(1);
child1(1245);
$s = microtime(true);
for($i =0; $i < 1000; $i++)
{
$arr = $table->get('350749960@qq.com');
}
echo "get -5 use: ".((microtime(true) - $s) * 1000)."ms\n";
$s = microtime(true);
//$table->incr('tianfenghan@qq.com', 'id', 5);
//$table->decr('hello@qq.com', 'num', 1.1);
$ret1 = $table->get('350749960@qq.com');
$ret2 = $table->get('tianfenghan@qq.com');
$ret3 = $table->get('350749960@qq.com');
$ret4 = $table->get('tianfenghan@qq.com');
$ret5 = $table->get('hello@qq.com');
echo "get -5 use: ".((microtime(true) - $s) * 1000)."ms\n";
var_dump($ret1, $ret2, $ret3, $ret4, $ret5);
echo "id:".$ret1['id']."\n";
echo "name:".$ret1['name']."\n";
echo "num:".$ret1['num']."\n";