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 would love any ideas! :) 1. Rolling your own database cache is probably not a fruitful exercise, except as a learning experience. Honest. The database vendors already have a cache you can use, and you're not going to beat their performance with your own in any kind of reasonable development time-frame. 2. You can't serialize the objects, connection, or result, from MySQL functions. I'm 100% certain of the connection object, and 99.9% certain of the result set object. Those objects go invalid when a script ends, no matter how you try to save them. You'll have to suck out all the data and store that. 3. Shared memory, last time I checked, was a real [bleep] to use because of a race condition in getting a unique name/semaphore for the storage space on a server-wide basis. Maybe this has changed since I last looked, but back in the day, you were taking the risk that your PHP shared memory would get trashed by, say, Perl using shared memory. Or any other application that wanted to use shared memory. I *hope* this has been fixed, for your sake, but be sure you read up on it. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php