<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/1.5.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: PHP: Client side caching for all MySQL extensions</title>
	<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/</link>
	<description>It's all about Nixnutz</description>
	<pubDate>Fri, 18 May 2012 20:32:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.2</generator>

	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Administrator</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113662</link>
		<pubDate>Fri, 25 Jun 2010 16:12:58 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113662</guid>
					<description>Oh, yes, it is mysqlnd_qc_get_core_stats() - fixed - thanks!</description>
		<content:encoded><![CDATA[	<p>Oh, yes, it is mysqlnd_qc_get_core_stats() - fixed - thanks!
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Nathaniel McHugh</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113661</link>
		<pubDate>Fri, 25 Jun 2010 16:05:58 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113661</guid>
					<description>Hi Ulf,

Excellent work, been having a play with this after I saw Johannes give your presentation at DPC couple weeks back.

Just wanted to point out a place where the docs at http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP#Installation don't match current API. I think mysqlnd_qc_get_core_statistics() has been renamed mysqlnd_qc_get_core_stats() or vice versa. Other than that instructions worked perfectly</description>
		<content:encoded><![CDATA[	<p>Hi Ulf,</p>
	<p>Excellent work, been having a play with this after I saw Johannes give your presentation at DPC couple weeks back.</p>
	<p>Just wanted to point out a place where the docs at <a href='http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP#Installation' rel='nofollow'>http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP#Installation</a> don&#8217;t match current API. I think mysqlnd_qc_get_core_statistics() has been renamed mysqlnd_qc_get_core_stats() or vice versa. Other than that instructions worked perfectly
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Administrator</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113659</link>
		<pubDate>Thu, 24 Jun 2010 17:18:38 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113659</guid>
					<description>Sebs: Pffft :-)</description>
		<content:encoded><![CDATA[	<p>Sebs: Pffft <img src='http://blog.ulf-wendel.de/wp-images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Sebs</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113658</link>
		<pubDate>Thu, 24 Jun 2010 17:10:05 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113658</guid>
					<description>Ich bin entzückt!!!!!
http://jetztimg.sueddeutsche.de/upl/images/user/di/dirk-vongehlen/346270.jpg

;)))))</description>
		<content:encoded><![CDATA[	<p>Ich bin entzückt!!!!!<br />
<a href='http://jetztimg.sueddeutsche.de/upl/images/user/di/dirk-vongehlen/346270.jpg' rel='nofollow'>http://jetztimg.sueddeutsche.de/upl/images/user/di/dirk-vongehlen/346270.jpg</a></p>
	<p>;)))))
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Johannes</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113657</link>
		<pubDate>Thu, 24 Jun 2010 14:29:57 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113657</guid>
					<description>...specially as PS emulation is on by default with PDO and in most scenarios you won't like the additional roundtrip for the prepare, anyways.</description>
		<content:encoded><![CDATA[	<p>&#8230;specially as PS emulation is on by default with PDO and in most scenarios you won&#8217;t like the additional roundtrip for the prepare, anyways.
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Administrator</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113655</link>
		<pubDate>Thu, 24 Jun 2010 13:29:55 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113655</guid>
					<description>PHPGangsta: How about using ZF with PDO and enabling PS emulation.... so, if you need it urgently</description>
		<content:encoded><![CDATA[	<p>PHPGangsta: How about using ZF with PDO and enabling PS emulation&#8230;. so, if you need it urgently
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: PHPGangsta</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113654</link>
		<pubDate>Thu, 24 Jun 2010 13:17:34 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113654</guid>
					<description>Really great news, the only negative thing is that prepared statements are not supported. Currently we are using Zend Framework which uses prepared statements internally (which is normally a good thing). :-(</description>
		<content:encoded><![CDATA[	<p>Really great news, the only negative thing is that prepared statements are not supported. Currently we are using Zend Framework which uses prepared statements internally (which is normally a good thing). <img src='http://blog.ulf-wendel.de/wp-images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Administrator</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113653</link>
		<pubDate>Thu, 24 Jun 2010 12:57:02 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113653</guid>
					<description>Glad to read you like it. 

Yes, user defined storage handler can (theoretically) lift the TTL invalidation strategy limitation and do whatever they want. It is certainly not an easy task but it is doable. 

Yes, the query cache does not work with MySQL native prepared statements because they have unbuffered results. Andrey can give you more details. He's the magician you need to talk to. By default PDO should use a prepared statement emulation for MySQL and that gives you buffered queries which can be cached. So, some users might not even know that and not realize the difference. It may just work for them.

I assume &quot;native PHP types&quot; refers to getting result sets from MySQL which use the PHP integer type for SQL INT column and so on.

Short anwer: mysqlnd can do the cast for you - at least with mysqli @ mysqlnd, check the mysqli tests from ext/mysqli/tests for MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 

When we talk about native types we need to distinguish between:

 - MySQL text protocol 
 - MySQL binary protocol
 - C level cast done within the extensions

You are correct that native prepared statements of MySQL use the binary protocol. The binary prototocol does not send strings over the wire. It will use the native types. This has a couple of advantages, see also http://blog.ulf-wendel.de/?p=198 . A MySQL integer column will become a PHP integer.

The classical mysql_query() (C-API) function will use the text protocol. Everything is converted into strings and send as a string over the wire. For years people have been happy with strings but in the times of P&amp;#166;JHAVA people want &quot;native PHP types&quot;. 

What can be done? You can tell the MySQL C extensions to do the casts for you based on metadata information - that is what MYSQLI_OPT_INT_AND_FLOAT_NATIVE is about. It gives you &quot;native PHP types&quot; even for the text protocol and mysql_query() (C-API).

Because the cache protoype does not work with native prepared statements you are forced to use buffered non prepared statements which get you back into the good all &quot;everything is a string&quot;-world.

This could be fixed by adding a MYSQLI_OPT_INT_AND_FLOAT_NATIVE  counterpart to the cache. Andrey is the expert...

Ulf</description>
		<content:encoded><![CDATA[	<p>Glad to read you like it. </p>
	<p>Yes, user defined storage handler can (theoretically) lift the TTL invalidation strategy limitation and do whatever they want. It is certainly not an easy task but it is doable. </p>
	<p>Yes, the query cache does not work with MySQL native prepared statements because they have unbuffered results. Andrey can give you more details. He&#8217;s the magician you need to talk to. By default PDO should use a prepared statement emulation for MySQL and that gives you buffered queries which can be cached. So, some users might not even know that and not realize the difference. It may just work for them.</p>
	<p>I assume &#8220;native PHP types&#8221; refers to getting result sets from MySQL which use the PHP integer type for SQL INT column and so on.</p>
	<p>Short anwer: mysqlnd can do the cast for you - at least with mysqli @ mysqlnd, check the mysqli tests from ext/mysqli/tests for MYSQLI_OPT_INT_AND_FLOAT_NATIVE, </p>
	<p>When we talk about native types we need to distinguish between:</p>
	<p> - MySQL text protocol<br />
 - MySQL binary protocol<br />
 - C level cast done within the extensions</p>
	<p>You are correct that native prepared statements of MySQL use the binary protocol. The binary prototocol does not send strings over the wire. It will use the native types. This has a couple of advantages, see also <a href='http://blog.ulf-wendel.de/?p=198' rel='nofollow'>http://blog.ulf-wendel.de/?p=198</a> . A MySQL integer column will become a PHP integer.</p>
	<p>The classical mysql_query() (C-API) function will use the text protocol. Everything is converted into strings and send as a string over the wire. For years people have been happy with strings but in the times of P|JHAVA people want &#8220;native PHP types&#8221;. </p>
	<p>What can be done? You can tell the MySQL C extensions to do the casts for you based on metadata information - that is what MYSQLI_OPT_INT_AND_FLOAT_NATIVE is about. It gives you &#8220;native PHP types&#8221; even for the text protocol and mysql_query() (C-API).</p>
	<p>Because the cache protoype does not work with native prepared statements you are forced to use buffered non prepared statements which get you back into the good all &#8220;everything is a string&#8221;-world.</p>
	<p>This could be fixed by adding a MYSQLI_OPT_INT_AND_FLOAT_NATIVE  counterpart to the cache. Andrey is the expert&#8230;</p>
	<p>Ulf
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on PHP: Client side caching for all MySQL extensions by: Josh Davis</title>
		<link>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113652</link>
		<pubDate>Thu, 24 Jun 2010 12:00:23 +0000</pubDate>
		<guid>http://blog.ulf-wendel.de/2010/php-client-side-caching-for-all-mysql-extensions/#comment-113652</guid>
					<description>I haven't read the article and presentation entirely, but that announcement got me PUMPED. I had a nerdgasm when I read that &quot;the standard TTL invalidation strategy can be replaced by user-defined ones&quot; even though I still have to uncover how it works.

Too bad that the cache doesn't work with PDO's prepared statement (or mysqli's for that matter.) Does that mean I have to choose between client-side caching and native PHP type?</description>
		<content:encoded><![CDATA[	<p>I haven&#8217;t read the article and presentation entirely, but that announcement got me PUMPED. I had a nerdgasm when I read that &#8220;the standard TTL invalidation strategy can be replaced by user-defined ones&#8221; even though I still have to uncover how it works.</p>
	<p>Too bad that the cache doesn&#8217;t work with PDO&#8217;s prepared statement (or mysqli&#8217;s for that matter.) Does that mean I have to choose between client-side caching and native PHP type?
</p>
]]></content:encoded>
				</item>
</channel>
</rss>

