Re: [PECL-DEV] Package proposal: a query cache plugin for mysqlnd

[email protected] (Ulf Wendel) Thu, 24 Jun 2010 13:54:05 +0200
Newsgroups php.pecl.dev
Message-ID <[email protected]>
Stan schrieb:

> This very interesting, as I was thinking about solution for transparent
> DB queries caching (but still in user control) as well, I definitely
> like low level solution like this. Just wanted to ask you whether there
> is a way to invalidate cached record on update or delete, or is it done
> automatically based on record key?

MySQL does not feature internal record ids.

User defined storage handler can lift the TTL limitation. BUT this has 
to be done on a case-by-case basis. It is your job to develop a user 
defined storage handler for your specific application.

User defined storage handler have to provide an is_select() function. 
The is_select() function gets called whenever a low level API call is 
made to run an unbuffered query. It will see all queries: deletes, 
inserts, updates and select. The function is expected to analyze the 
query and decide wheter its results shall be added to the cache or not.

If your user defined is_select() detects an update or delete you can 
manually invalidate and flush those cache entries which are affected by 
the update or delete. MySQL won't help you with this task. It is up to 
you to detect dependencies and to proper invalidation.

Ultimately I see this as something that you probably want to try and 
fiddle out in user space first before you even consider to move any such 
logic into C. I doubt its possible to find a solid and generic 
implementation.

But you may try - in user space - the cache has the necessary features.

Ulf