Package proposal

From: Date: Sun, 10 Oct 2004 07:04:10 +0000
Subject: Package proposal
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-33742@lists.php.net to get a copy of this message
Hello pear-dev, We have faced with necessity to have some MySQL API allowing to cache SQL queries results as we had lots of same but very resources consuming queries returning same data each time in our several last projects. We have looked through packages available in 'Database' section of PEAR packages collection and did not find anything suitable. As MySQL API in PHP4 do not support even queries preparation we have created caching package for our purposes and we hope it can be useful for rest PHP community. So, we have following: I. GENERAL DESCRIPTION This is set of classes intended to replace current 'DB' family of classes in order to provide programmer with caching capabilities of equal queries preserving almost same classes interface. (Same queries are queries having equal SQL text). Programmer explicitly orders to use caching mechanism for certain query. Caching mechanism automatically determines data modification queries (DELETE, INSERT, REPLACE, UPDATE) and invalidates caches of queries using modified tables. Caching mechanism has internal garbage collector. II. FEATURES 1. Classes interface copies interface of 'DB' classes family mainly. So it makes it simple to move from one set of classes to another when using MySQL. 2. Caching mechanism is turned on explicitly for certain query not for all queries to MySQL. 3. Caching mechanism detects data modification queries (this is correct if all modifications queries are executed through this MySQL API) and invalidates caches of queries related to modified tables. 3. Caching mechanism has built in garbage collector. GC deletes data of queries executed too long ago. 4. Caching mechanism can be easily extended by adding arbitrary data serialization and data storing algorithms. Standard PHP serialization/unserialization algorithm and plain files based data storing are implemented for now. 5. In order to simplify MySQL API object creation 'Builder' design template is used. It allows to describe API configuration in arbitrary configuration file or data store. One of possible implementation of this idea based on PHP standard INI files are introduced. III. DESIGN TEMPLATES We tried to make these classes as more extendible as we could. So we used following design templates: 1. Template Method - to encapsulate internal objects creation mechanism. 2. Strategy - to encapsulate data serialization/unserialization algorithms and data input/output algorithms. 3. Builder - to encapsulate process of creation and initialization of MySQL API object. This allows to describe desired API configuration in arbitrary form known to concrete implementation of Builder. IV. DISADVANTAGES 1. These classes do not completely copy 'DB' class family interface. So they are not completely compatible. 2. Due to strange work of PHP4 'mysql_affected_rows' function data modification queries detection is based on queries text parsing. V. SOURCES Sources with simple usage example and documentation can be obtained here: http://demo.itscript.com/src/pear.tar.gz -- Best regards, Maxim Antipin (ITScript CEO) mailto:max@itscript.com

« previous php.pear.dev (#33742) next »