RE: [PHP] Cacheing data form PHP script
| From: | Gryffyn, Trevor | Date: | Wed, 28 Jan 2004 23:51:06 +0000 |
| Subject: | RE: [PHP] Cacheing data form PHP script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176145@lists.php.net to get a copy of this message | ||
It's not really that bad, maybe I just made it sound complicated and
annoying.
(pseudo-php)
If (dataexistsindb) {
$cachedata = SELECT cachedata from DB
$dataarr = unserialize(cachedata)
} else {
$dataarr = SELECT freshdata
$cachedata = serialize($dataarr)
INSERT or UPDATE $cachedata into DB
// INSERT if you want to keep a history of cachedata
// UPDATE or I guess REPLACE if you want to keep just one copy of
the cache
}
If you make changes during the day and/or to just do another
UPDATE/REPLACE.. Either looking for the single record or the one with
today's date on it.
-TG
> Seems like a huge headache, maybe store the array in a
> session is the best
> bet, but then yes what if one of the admins goes into manage
> tool i built
> to manage the data on the pulldown menus ? So would you
> suggest store the
> array in a cache table as serialized, then if we update
> replace the data ,
> using REPLACE ?