Re: [Phplib-users] Caching MySQL queries
Brought to you by:
nhruby,
richardarcher
From: Donncha O C. <don...@tr...> - 2001-10-26 15:37:47
|
"nathan r. hruby" wrote: > > On Fri, 26 Oct 2001, Donncha O Caoimh wrote: > > > That's the simple explanation. I serialize the array and base64_encode > > it before caching it and seperate each record by a "\n". When I read it > > back I split the cache by "\n" and eval() the correct row. Not the best > > way of doing it but it's the most obvious way I thought of and the > > quickest to see if it'd work :) > > > > I picked up on this late, so please shoot me if I'm straying or this has > been covered. > > base64 encoding increases the size of stored vaules by a lot which could > be part of the problem when working with large result sets. Unless you > need base64 I'd say just to just serialize the mysql result arrays, add > whatever delim you nedd and addslash() them then jsut stripslash(), > split() and eval() Did that and it's easier to debug the cache now.. mimencode just makes sure that things are def. not 8 bit characters.. > > Question is what kind of metadata does the cache have to make sure the > data is fresh and to determine a hit (looking back, md5 sums of the > original sql query statement.. i see that should work) and where does this > cache live? If it's living in a db, well, then what's the point except to > speed up very complex queries. Now if it's living in a shmem ssegment, > well, that's just darn fast.. With something like Zend cache, you may be > able to use a file and let *that* cache engine take care of it too, if you > don't feel like coding your own shmem functions I haven't even looked at that yet. All I'm doing is setting an arbitrary timeout on every query. The cache gets stored in /tmp at the moment. Again, I'm trying to get it to work first before I do anything exotic with it. And also allowing for dropping in other caching scripts too. Donncha. |