laruence / yac Goto Github PK
View Code? Open in Web Editor NEWA fast, lock-free, shared memory user data cache for PHP
License: Other
A fast, lock-free, shared memory user data cache for PHP
License: Other
这个错误是由什么引起的?
RT在命令行下面运行存储的数据,在Web端读不出来吗?
yac和memcache性能对比测试 https://yq.aliyun.com/articles/27323 这里是详细过程@laruence 鸟哥看下是咋回事?
<?php
function test_memcache_set(){
$mem = memcache_connect('127.0.0.1', 11211);
$value = mt_rand();
$res = memcache_set($mem, 'var_key', $value, false, 3000);
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
}
}
function test_memcache_get(){
$mem = memcache_connect('127.0.0.1', 11211);
$res = memcache_get($mem, 'var_key');
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
} else {
echo $res;
}
}
function test_yac_set(){
$yac = new Yac();
$value = mt_rand();
$res = $yac->set('var_key', $value);
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
}
}
function test_yac_get(){
$yac = new Yac();
$res = $yac->get('var_key');
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
} else {
echo $res;
}
}
echo $_GET["m"]();
?>
ab -t 10 -c 20 http://10.32.232.129/test.php?m=test_yac_get
Complete requests: 1220
Failed requests: 829
(Connect: 0, Length: 829, Exceptions: 0)
Time per request: 164.116 [ms] (mean)
Complete requests: 1300
Failed requests: 809
(Connect: 0, Length: 809, Exceptions: 0)
Time per request: 154.907 [ms] (mean)
如果有2个对象:
$yac1 = new Yac('a');
$yac1->set('test', 'a');
$yac2 = new Yac('b');
$yac2->set('test', 'b');
$yac1->flush();
var_dump($yac2->get('test')); // false
任意一个对象执行 flush() 操作,则会清空所有数据,包括其它对象的数据,这样是不是不够“友好”?
当然,我明白 new Yac() 里的参数只是一个前缀的区别,然而使用 Yac::flush()
这样执行会报错,这并不是一个静态方法,必须 $yac->flush()
这样执行,这种调用方法往往程序开发会认为是清空当前对象的数据,而不是整个yac数据
鸟哥,在里面用PHPUnit对控制器测试时,Yac对象能创建成功,但是,没有任何方法和成员变量。在浏览器下访问时,一切正常。
环境:
首先,看一下控制器代码:
public function indexAction()
{
$yac = new \Yac('user');
dump($yac);
dump($yac->info());
die();
}
下面是,symfony的测试代码:
public function testIndex()
{
$client = static::createClient(array(), array('HTTP_HOST' => 'abc.com'));
$client->request('GET', '/');
}
再看一下phpunit的结果:
➜ symfony git:(master) ✗ phpunit -c app
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.
Configuration read from /Users/xxxx/xxxxx/symfony/app/phpunit.xml.dist
DefaultController.php on line 28:
Yac {#321
#_prefix: ""
}
DefaultController.php on line 29:
false
然后,在浏览器访问时,是正常的:
DefaultController.php on line 28:
Yac {#294
#_prefix: "user"
}
{"memory_size":71303168,"slots_memory_size":4194304,"values_memory_size":67108864,"segment_size":4194304,"segment_num":16,"miss":0,"hits":0,"fails":0,"kicks":0,"recycles":0,"slots_size":32768,"slots_used":0}
不清楚是phpunit模拟请求的问题,还是yac的问题。还请鸟哥指点一二。
Because of droped IS_CONSTANT_ARRAY...
$functions = get_extension_funcs("yac"); return boolean(false)
php version:
PHP 7.1.0-dev (cli) (built: Apr 15 2016 09:37:48) ( NTS DEBUG )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
下载 https://pecl.php.net/get/yac-2.0.1.tgz
make 时出现如下错误:
/bin/sh /root/yac-2.0.1/libtool --mode=compile cc -I. -I/root/yac-2.0.1 -DPHP_ATOM_INC -I/root/yac-2.0.1/include -I/root/yac-2.0.1/main -I/root/yac-2.0.1 -I/usr/local/php5.6.22/include/php -I/usr/local/php5.6.22/include/php/main -I/usr/local/php5.6.22/include/php/TSRM -I/usr/local/php5.6.22/include/php/Zend -I/usr/local/php5.6.22/include/php/ext -I/usr/local/php5.6.22/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/yac-2.0.1/yac.c -o yac.lo
mkdir .libs
cc -I. -I/root/yac-2.0.1 -DPHP_ATOM_INC -I/root/yac-2.0.1/include -I/root/yac-2.0.1/main -I/root/yac-2.0.1 -I/usr/local/php5.6.22/include/php -I/usr/local/php5.6.22/include/php/main -I/usr/local/php5.6.22/include/php/TSRM -I/usr/local/php5.6.22/include/php/Zend -I/usr/local/php5.6.22/include/php/ext -I/usr/local/php5.6.22/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/yac-2.0.1/yac.c -fPIC -DPIC -o .libs/yac.o
/root/yac-2.0.1/yac.c:30:28: error: zend_smart_str.h: No such file or directory
In file included from /root/yac-2.0.1/yac.c:35:
/root/yac-2.0.1/serializer/yac_serializer.h:28: error: expected declaration specifiers or ‘...’ before ‘smart_str’
/root/yac-2.0.1/yac.c: In function ‘OnChangeKeysMemoryLimit’:
/root/yac-2.0.1/yac.c:82: warning: passing argument 1 of ‘zend_atol’ makes pointer from integer without a cast
/usr/local/php5.6.22/include/php/Zend/zend_operators.h:377: note: expected ‘const char ’ but argument is of type ‘int’
/root/yac-2.0.1/yac.c: In function ‘OnChangeValsMemoryLimit’:
/root/yac-2.0.1/yac.c:90: warning: passing argument 1 of ‘zend_atol’ makes pointer from integer without a cast
/usr/local/php5.6.22/include/php/Zend/zend_operators.h:377: note: expected ‘const char *’ but argument is of type ‘int’
/root/yac-2.0.1/yac.c: In function ‘OnChangeCompressThreshold’:
/root/yac-2.0.1/yac.c:98: warning: passing argument 1 of ‘zend_atol’ makes pointer from integer without a cast
/usr/local/php5.6.22/include/php/Zend/zend_operators.h:377: note: expected ‘const char *’ but argument is of type ‘int’
/root/yac-2.0.1/yac.c: At top level:
/root/yac-2.0.1/yac.c:119: error: expected ‘)’ before ‘’ token
/root/yac-2.0.1/yac.c:270: error: expected ‘)’ before ‘’ token
/root/yac-2.0.1/yac.c:299: error: expected ‘)’ before ‘’ token
/root/yac-2.0.1/yac.c:366:38: error: macro "ZVAL_STRINGL" requires 4 arguments, but only 3 given
/root/yac-2.0.1/yac.c:370:34: error: macro "ZVAL_STRINGL" requires 4 arguments, but only 3 given
/root/yac-2.0.1/yac.c:426: error: expected ‘)’ before ‘’ token
/root/yac-2.0.1/yac.c: In function ‘yac_delete_multi_impl’:
/root/yac-2.0.1/yac.c:493: error: expected ‘;’ before ‘{’ token
/root/yac-2.0.1/yac.c: In function ‘zim_yac___construct’:
/root/yac-2.0.1/yac.c:514: error: ‘zend_string’ undeclared (first use in this function)
/root/yac-2.0.1/yac.c:514: error: (Each undeclared identifier is reported only once
/root/yac-2.0.1/yac.c:514: error: for each function it appears in.)
/root/yac-2.0.1/yac.c:514: error: ‘prefix’ undeclared (first use in this function)
/root/yac-2.0.1/yac.c: In function ‘zim_yac_add’:
/root/yac-2.0.1/yac.c:573: error: too many arguments to function ‘zend_read_property’
/root/yac-2.0.1/yac.c:581: error: too few arguments to function ‘zend_make_printable_zval’
/root/yac-2.0.1/yac.c: In function ‘zim_yac_set’:
/root/yac-2.0.1/yac.c:630: error: too many arguments to function ‘zend_read_property’
/root/yac-2.0.1/yac.c:638: error: too few arguments to function ‘zend_make_printable_zval’
/root/yac-2.0.1/yac.c: In function ‘zim_yac___set’:
/root/yac-2.0.1/yac.c:650: error: ‘zend_string’ undeclared (first use in this function)
/root/yac-2.0.1/yac.c:650: error: ‘key’ undeclared (first use in this function)
/root/yac-2.0.1/yac.c:661: error: too many arguments to function ‘zend_read_property’
/root/yac-2.0.1/yac.c: In function ‘zim_yac_get’:
/root/yac-2.0.1/yac.c:681: error: too many arguments to function ‘zend_read_property’
/root/yac-2.0.1/yac.c:684: warning: assignment makes pointer from integer without a cast
/root/yac-2.0.1/yac.c:686: warning: assignment makes pointer from integer without a cast
/root/yac-2.0.1/yac.c:689: error: too few arguments to function ‘zend_make_printable_zval’
/root/yac-2.0.1/yac.c:690: warning: assignment makes pointer from integer without a cast
/root/yac-2.0.1/yac.c: In function ‘zim_yac___get’:
/root/yac-2.0.1/yac.c:704: error: ‘zend_string’ undeclared (first use in this function)
/root/yac-2.0.1/yac.c:704: error: ‘key’ undeclared (first use in this function)
/root/yac-2.0.1/yac.c:715: error: too many arguments to function ‘zend_read_property’
/root/yac-2.0.1/yac.c: In function ‘zim_yac_delete’:
/root/yac-2.0.1/yac.c:739: error: too many arguments to function ‘zend_read_property’
/root/yac-2.0.1/yac.c:749: error: too few arguments to function ‘zend_make_printable_zval’
/root/yac-2.0.1/yac.c:829:47: error: macro "add_assoc_string" requires 4 arguments, but only 3 given
/root/yac-2.0.1/yac.c: In function ‘zim_yac_dump’:
/root/yac-2.0.1/yac.c:829: error: ‘add_assoc_string’ undeclared (first use in this function)
make: ** [yac.lo] Error 1
Fatal error: Shared memory allocator startup failed at 'info.State': No such file or directory in Unknown on line 0
[storage/allocator/allocators/shm.c:127]: (error) Memory leak: shared_segments
[storage/allocator/yac_allocator.c:56]: (error) Possible null pointer dereference: segments
[storage/allocator/yac_allocator.c:57]: (error) Possible null pointer dereference: segments
[storage/allocator/yac_allocator.c:54]: (error) Uninitialized variable: segments_num
error C2036:'void *' : unknown size void* at yac_allocator.c line 113
yac-2.0.0/yac.c:30:28: error: zend_smart_str.h: No such file or directory
希望能够实现一个遍历的的迭代器的功能,如果能根据前缀区别再实现 count() 方法就最好了~
使用 Yac 偶然遇到这种情况,然后就开始刷屏了。
I would like to ask kindly if there are any plans to bring yac to pecl? I would love to get an easy way to install yac along with opcache to fit our needs of opcode- and userland-caching.
请问这个跟memcache有什么区别?
因多业务在同一服务器,个人比较想要
flush只会删除当前前缀下的数据
flushAll 所有数据
希望考虑一下,谢谢。
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
expr: syntax error
./configure: line 2519: test: =: unary operator expected
expr: syntax error
./configure: line 2526: test: =: unary operator expected
expr: syntax error
./configure: line 2533: test: =: unary operator expected
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
提示错误
expr: syntax error
./configure: line 2519: test: =: unary operator expected
expr: syntax error
./configure: line 2526: test: =: unary operator expected
expr: syntax error
./configure: line 2533: test: =: unary operator expected
不知道会有影响吗?
key 保存不进去。
set("foo", "bar"); $yac->set( array( "dummy" => "foo", "dummy2" => "foo", ) ); var_dump($yac->get("dummy")); 获取到是false ,文档中提示的常量是可以打印的。不知道怎么联系你,也不知道写这里合不合适。
原来正常的,怎么今天重新编译后不能用了?
难道key的长度超了?还是新版限制更严格了?
$this->connect = new Yac( $identifier );
$this->connect->set( md5( $this->identifier . $key ), $value, $ttl );
README里并没有提到这个方法,但是我用 ReflectionClass 看到了这个方法,当 delete() 一个key 后在 dump() 的话,那个 key 对应的信息还在,只是返回的 ttl 由0变成了1。
Array
(
[0] => Array
(
[index] => 168930
[hash] => 3657602018
[crc] => 2675899467
[ttl] => 0
[k_len] => 1
[v_len] => 15
[size] => 128
[key] => 7
)
)
删除前
Array
(
[0] => Array
(
[index] => 168930
[hash] => 3657602018
[crc] => 2675899467
[ttl] => 1
[k_len] => 1
[v_len] => 15
[size] => 128
[key] => 7
)
)
删除后。
装上msgpack扩展后解决
inc(key, amt, ttl) /
dec(...) /
add /
push / pull / shift / unshift (working with arrays)
is_in
lock / unlock
See https://travis-ci.org/marc-mabe/zend-cache/jobs/98510360
(search for $ if [[ $PECL_INSTALL_YAC != '' ]]; then pecl install $PECL_INSTALL_YAC && phpenv config-add .ci/yac.ini || return 0 ; fi
)
$ if [[ $PECL_INSTALL_YAC != '' ]]; then pecl install $PECL_INSTALL_YAC && phpenv config-add .ci/yac.ini || return 0 ; fi
downloading yac-2.0.0.tgz ...
Starting to download yac-2.0.0.tgz (32,600 bytes)
.........done: 32,600 bytes
16 source files, building
running: phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
building in /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0
running: /tmp/pear/temp/yac/configure --with-php-config=/home/travis/.phpenv/versions/7.0.0/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /home/travis/.phpenv/versions/7.0.0
checking for PHP includes... -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib
checking for PHP extension directory... /home/travis/.phpenv/versions/7.0.0/lib/php/extensions/no-debug-zts-20151012
checking for PHP installed headers prefix... /home/travis/.phpenv/versions/7.0.0/include/php
checking if debug is enabled... no
checking if zts is enabled... yes
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... gawk
checking whether to enable yac support... yes, shared
checking wheter to use system FastLZ bibrary... no
checking for sysvipc shared memory support... yes
checking for mmap() using MAP_ANON shared memory support... yes
checking for mmap() using /dev/zero shared memory support... yes
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/yac.c -o yac.lo
mkdir .libs
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/yac.c -fPIC -DPIC -o .libs/yac.o
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/yac_storage.c -o storage/yac_storage.lo
mkdir storage/.libs
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/yac_storage.c -fPIC -DPIC -o storage/.libs/yac_storage.o
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/allocator/yac_allocator.c -o storage/allocator/yac_allocator.lo
mkdir storage/allocator/.libs
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/allocator/yac_allocator.c -fPIC -DPIC -o storage/allocator/.libs/yac_allocator.o
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/allocator/allocators/shm.c -o storage/allocator/allocators/shm.lo
mkdir storage/allocator/allocators/.libs
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/allocator/allocators/shm.c -fPIC -DPIC -o storage/allocator/allocators/.libs/shm.o
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/allocator/allocators/mmap.c -o storage/allocator/allocators/mmap.lo
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/allocator/allocators/mmap.c -fPIC -DPIC -o storage/allocator/allocators/.libs/mmap.o
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/serializer/php.c -o serializer/php.lo
mkdir serializer/.libs
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/serializer/php.c -fPIC -DPIC -o serializer/.libs/php.o
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/serializer/msgpack.c -o serializer/msgpack.lo
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/serializer/msgpack.c -fPIC -DPIC -o serializer/.libs/msgpack.o
/bin/bash /tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/include -I/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/7.0.0/include/php -I/home/travis/.phpenv/versions/7.0.0/include/php/main -I/home/travis/.phpenv/versions/7.0.0/include/php/TSRM -I/home/travis/.phpenv/versions/7.0.0/include/php/Zend -I/home/travis/.phpenv/versions/7.0.0/include/php/ext -I/home/travis/.phpenv/versions/7.0.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/compressor/fastlz/fastlz.c -o compressor/fastlz/fastlz.lo
/tmp/pear/temp/pear-build-travisWjsBm6/yac-2.0.0/libtool: line 1283: compressor/fastlz/fastlz.loT: No such file or directory
mkdir compressor/fastlz/.libs
mkdir: cannot create directory `compressor/fastlz/.libs': No such file or directory
make: *** [compressor/fastlz/fastlz.lo] Error 1
ERROR: `make' failed
$ if [[ $PECL_INSTALL_YAC != '' ]]; then pecl install $PECL_INSTALL_YAC && phpenv config-add .ci/yac.ini || return 0 ; fi
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading yac-0.9.2.tgz ...
Starting to download yac-0.9.2.tgz (34,822 bytes)
.........done: 34,822 bytes
18 source files, building
running: phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
building in /tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2
running: /tmp/pear/temp/yac/configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /home/travis/.phpenv/versions/5.5.21
checking for PHP includes... -I/home/travis/.phpenv/versions/5.5.21/include/php -I/home/travis/.phpenv/versions/5.5.21/include/php/main -I/home/travis/.phpenv/versions/5.5.21/include/php/TSRM -I/home/travis/.phpenv/versions/5.5.21/include/php/Zend -I/home/travis/.phpenv/versions/5.5.21/include/php/ext -I/home/travis/.phpenv/versions/5.5.21/include/php/ext/date/lib
checking for PHP extension directory... /home/travis/.phpenv/versions/5.5.21/lib/php/extensions/no-debug-zts-20121212
checking for PHP installed headers prefix... /home/travis/.phpenv/versions/5.5.21/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... gawk
checking whether to enable yac support... yes, shared
checking wheter to use system FastLZ bibrary... no
checking for sysvipc shared memory support... yes
checking for mmap() using MAP_ANON shared memory support... yes
checking for mmap() using /dev/zero shared memory support... yes
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/bash /tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/include -I/tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/5.5.21/include/php -I/home/travis/.phpenv/versions/5.5.21/include/php/main -I/home/travis/.phpenv/versions/5.5.21/include/php/TSRM -I/home/travis/.phpenv/versions/5.5.21/include/php/Zend -I/home/travis/.phpenv/versions/5.5.21/include/php/ext -I/home/travis/.phpenv/versions/5.5.21/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/yac.c -o yac.lo
mkdir .libs
cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/include -I/tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/5.5.21/include/php -I/home/travis/.phpenv/versions/5.5.21/include/php/main -I/home/travis/.phpenv/versions/5.5.21/include/php/TSRM -I/home/travis/.phpenv/versions/5.5.21/include/php/Zend -I/home/travis/.phpenv/versions/5.5.21/include/php/ext -I/home/travis/.phpenv/versions/5.5.21/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/yac.c -fPIC -DPIC -o .libs/yac.o
/bin/bash /tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/libtool --mode=compile cc -I. -I/tmp/pear/temp/yac -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/include -I/tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/main -I/tmp/pear/temp/yac -I/home/travis/.phpenv/versions/5.5.21/include/php -I/home/travis/.phpenv/versions/5.5.21/include/php/main -I/home/travis/.phpenv/versions/5.5.21/include/php/TSRM -I/home/travis/.phpenv/versions/5.5.21/include/php/Zend -I/home/travis/.phpenv/versions/5.5.21/include/php/ext -I/home/travis/.phpenv/versions/5.5.21/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/yac/storage/yac_storage.c -o storage/yac_storage.lo
/tmp/pear/temp/pear-build-travistT8kbp/yac-0.9.2/libtool: line 1283: storage/yac_storage.loT: No such file or directory
mkdir storage/.libs
mkdir: cannot create directory `storage/.libs': No such file or directory
make: *** [storage/yac_storage.lo] Error 1
ERROR: `make' failed
cannot be built statically, but built as a "so" is ok.
hi 鸟哥,
我们在线上应用yac的时候遇到了一个问题:
如果使用yac的默认配置(4M/64M),运行起来是没有问题的,但是把缓存空间翻倍就会大概每隔5分钟遇到:
[pool p-web-0] child 21377 exited on signal 11 (SIGSEGV - core dumped) after 262.000868 seconds from start
附上yac的配置
yac.enable = 1
yac.keys_memory_size = 8M
yac.values_memory_size = 128M
yac.compress_threshold = -1
<?php
$yac = new Yac();
$yac->set('950ff7a54a39bdce5304700e17a5a0cd', array(1 => 10), 10099990);
var_dump($yac->get('950ff7a54a39bdce5304700e17a5a0cd'));
php test.php 输出
array(1) {
[1]=>
int(10)
}
当注释掉这行,
set('950ff7a54a39bdce5304700e17a5a0cd', array(1 => 10), 10099990); var_dump($yac->get('950ff7a54a39bdce5304700e17a5a0cd')); ``` php test.php,输出 false。why? ```Hi,
when I execute this script:
http://pastebin.com/tUYUnxef
with this Apache Bench command line options:
ab -H "Connection:close" -c 20 -n 500 http://www/test_yac.php
I get this result:
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking ditta (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests
Server Software: Apache/2.2.25
Server Hostname: ditta
Server Port: 80
Document Path: /test_yac.php
Document Length: 0 bytes
Concurrency Level: 20
Time taken for tests: 112.869 seconds
Complete requests: 500
Failed requests: 2
(Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
Write errors: 0
Total transferred: 116772 bytes
HTML transferred: 268 bytes
Requests per second: 4.43 [#/sec] (mean)
Time per request: 4514.759 [ms] (mean)
Time per request: 225.738 [ms] (mean, across all concurrent requests)
Transfer rate: 1.01 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 3 1.5 3 28
Processing: 1756 4478 890.6 4436 10193
Waiting: 1756 4478 889.9 4436 10193
Total: 1758 4481 890.6 4438 10196
Percentage of the requests served within a certain time (ms)
50% 4438
66% 4685
75% 4826
80% 4937
90% 5264
95% 5808
98% 6991
99% 7489
100% 10196 (longest request)
The errors are:
Warning: Yac::get(): Unserialization failed in /usr/local/www/data.default/test_yac.php on line 26
Warning: Yac::get(): Unserialization failed in /usr/local/www/data.default/test_yac.php on line 26
And this can be reproduced - you get always some erroneous responses
我在多台机器(web,后台定时job)使用yac共享了一些配置(Shared memory model => mmap)。
在nmap.c中,yac申请了匿名共享内存:
first_segment.common.p = mmap(0, allocate_size, PROT_READ | PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
所以在fpm模式,多个php请求可以共享yac中的配置缓存,但是在定时任务服务器,多个php定时任务是不能共享yac中的配置缓存。
这样定时job服务器就不能使用yac缓存配置信息了,和web不统一。
如果暴力的修改nmap.c参数,多个没有亲缘关系的进程共享一个fd,取消MAP_ANONYMOUS,不知道会不会有什么风险..
need to talk to mysql guys later. record here..
php7下尝试ENABLE_MSGPACK,然后报ext/standard/php_smart_str.h file not found错误。请问是不是php7默认的序列化/反序列化效率大增,已经没有enable msgpack的必要了?
用源代码make(PHP 5.5.14)过, 也用brew(php 5.5.23)安装过, 都不行.
yaf 源代码安装运行起来了的.
系统环境:
gcc version 4.8.3 20140911 (Red Hat 4.8.3-9)
CentOS Linux release 7.2.1511 (Core)
LNMP环境:
Nginx版本:1.8.1
Php版本:7.1.0-dev
MySQL版本:5.7.11
php7安装路径:/usr/local/php7/,使用pecl安装yac命令如下:
/usr/local/php7/bin/pecl install channel://pecl.php.net/yac-2.0.0
安装不成功,安装时提示错误:
mkdir compressor/fastlz/.libs
mkdir: cannot create directory 'compressor/fastlz/.libs': No such file or directory
make: *** [compressor/fastlz/fastlz.lo] Error 1
ERROR: `make' failed
希望鸟哥能抽空解决一下。
Similar to apc_add() to help avoid thundering herd issues on a cold cache
编译Yac时出现下面问题:
cc -I. -I/Users/Anoxia/Downloads/yac-2.0.0 -DPHP_ATOM_INC -I/Users/Anoxia/Downloads/yac-2.0.0/include -I/Users/Anoxia/Downloads/yac-2.0.0/main -I/Users/Anoxi
a/Downloads/yac-2.0.0 -I/usr/local/Cellar/php56/5.6.17/include/php -I/usr/local/Cellar/php56/5.6.17/include/php/main -I/usr/local/Cellar/php56/5.6.17/include/
php/TSRM -I/usr/local/Cellar/php56/5.6.17/include/php/Zend -I/usr/local/Cellar/php56/5.6.17/include/php/ext -I/usr/local/Cellar/php56/5.6.17/include/php/ext/d
ate/lib -DHAVE_CONFIG_H -g -O0 -c /Users/Anoxia/Downloads/yac-2.0.0/yac.c -fno-common -DPIC -o .libs/yac.o
/Users/Anoxia/Downloads/yac-2.0.0/yac.c:30:10: fatal error: 'zend_smart_str.h' file not found
i print YAC_MAX_VALUE_RAW_LEN is 67108863 , that is large than 3211227 bytes.
here is my yac config :
yac
yac support => enabled
Version => 0.9.3-dev
Shared Memory => mmap
Serializer => php
Directive => Local Value => Master Value
yac.compress_threshold => -1 => -1
yac.debug => On => On
yac.enable => On => On
yac.enable_cli => 0 => 0
yac.keys_memory_size => 32M => 32M
yac.values_memory_size => 32M => 32M
如果业务本身需要,存的value为false时,很容易混淆。不知道是不存在这个key,还是key的值就是false。两点建议:
Is there any possibility to flush the whole cache besides to restart the server? If no, are there any plans to implement such a feature?
I need get the expiration time to set the http headers like expire.
xiexie.
will it be feasable to add apc compatibility layer ?
I build yac on my homebrewe'd php 5.4.12 on my macbook with OSX. I try to run one of your test-scripts from the blogpost and yac exits with the message "Abort trap: 6".
As it might be related. While compiling yac, I got those 2 warnings:
"yac/storage/allocator/allocators/mmap.c:89:4: warning: implicit declaration of function 'assert' is invalid in C99 [-Wimplicit-function-declaration]
assert(i == (segments_num - 1));
^
yac/storage/allocator/allocators/mmap.c:112:2: warning: incompatible pointer types initializing 'create_segments_t' (aka 'int ()(unsigned long, unsigned long,
yac_shared_segment *, int , char *)') with an expression of type 'int (unsigned long, unsigned long, yac_shared_segment_mmap *, int *, char *)'
[-Wincompatible-pointer-types]
create_segments,
^~~~~~~~~~~~~~~"
As I dont know what you may need to know, please dont hesitate to ask for further informations.
Hi,
I have some variables containing bool(false) or bool(true) I'd like to add and get. The problem is now, when I store false and get it back later, I don't know if false was stored, or the key is unknown to yac.
In Memcached for example I can check Memcached::getResultCode() with Memcached::RES_NOTFOUND.
In Yac, when false is returned, I have to do all this expensive-SQL-stuff to re-determine the information.
Hi, I've taken your example from http://www.laruence.com/2013/03/18/2846.html and you are right Yac seems to be quite faster as apc is. So I moved it to a real case program, where some results from the database are cached, but found out, that Yac is a little slower (not much, but 10 %). After playing around with your example, I found out, that apc is slower only in cases, where the key is longer than a certain length. Your example with 10000 rounds gives me:
Yac:
$yac = new Yac();
$start = microtime(true);
for ($i = 0; $i<10000; $i++) {
$key = "xxx" . rand(1, 10000);
$value = str_repeat("x", rand(1, 10000));
if (!$yac->set($key, $value)) {
var_dump("write " . $i);
}
if ($value != ($new = $yac->get($key))) {
var_dump("read " . $i);
}
}
echo (microtime(true)-$start).'<br />';
$start = microtime(true);
for ($i = 0; $i<10000; $i++) {
$key = "xxx" . rand(1, 10000);
$value = str_repeat("x", rand(1, 10000));
if (!apc_store($key, $value)) {
var_dump("write " . $i);
}
if ($value != ($new = apc_fetch($key))) {
var_dump("read " . $i);
}
}
echo (microtime(true)-$start).'<br />';
Yac:
0.11415910720825 <- Yac faster
APC:
0.12692189216614
$yac = new Yac();
$start = microtime(true);
for ($i = 0; $i<10000; $i++) {
$key = md5("y" . rand(1, 100)); // <- the key length is the only difference!
$value = str_repeat("x", rand(1, 10000));
if (!$yac->set($key, $value)) {
var_dump("write " . $i);
}
if ($value != ($new = $yac->get($key))) {
var_dump("read " . $i);
}
}
echo (microtime(true)-$start).'<br />';
?>
APC:
<?php
$start = microtime(true);
for ($i = 0; $i<10000; $i++) {
$key = md5("y" . rand(1, 100)); // <- the key length is the only difference!
$value = str_repeat("x", rand(1, 10000));
if (!apc_store($key, $value)) {
var_dump("write " . $i);
}
if ($value != ($new = apc_fetch($key))) {
var_dump("read " . $i);
}
}
echo (microtime(true)-$start).'<br />';
Yac:
0.11087489128113
APC:
0.094645977020264 <- APC is faster
In most cases this will be no problem, as Yac is on very constant speed, but in the cases I testet over a longer period, apc seems to be a better choice so far. Maybe my investigation will help you to improve Yac. 👍
这个在调试和维护的时候十分有用,可以随时查看当前所有缓存中的键值对
我的配置:
; Enable Yet Another Cache extension module
extension = yac.so
yac.enable=1
yac.enable_cli=1
;yac.debug=0
yac.keys_memory_size=16M
yac.values_memory_size=128M
;yac.compress_threshold=-1
php version
PHP 7.0.0 (cli) (built: Dec 3 2015 18:05:30) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
但是还是报错
Yac::set(): Value is too big to be stored
请问,需要如何设置才可以避免这个错误?
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.