Re: Implementing database cache.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Bruno b b magalhães wrote:
does anybody have am idea of witch are the required functions to implement a database query cache? I have a very nice and fast database layer, witch I use in all my projects (about 19 sites and a lot of others hot-sites and systems like intranet and extranets). Here is my idea of the functions:

is_cached();
read_cache();
clear_cache();
write_cache();

And what is the fastest way, shared memory perhaps? And I would have to use serialize function to store query results right? and about the cache name (or cache_id whatever) I was thinking about using a md5 hash of the query itself.

I use this class below to cache arbitrary data, for a given period or until you an arbitrary moment when something else is updated in your site.


http://www.phpclasses.org/filecache

Of course, you can use it to retrieve the results into an array and store the serialized array in the cache.

However, in practice it is much more efficient if you cache the actual HTML of the pages that are generated from one or more queries. This way you may be saving many more database access queries with a single cache and also the actual CPU time your script takes to generate the cached HTML pages.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux