Index: Cache.php =================================================================== RCS file: /repository/pear/Cache/Cache.php,v retrieving revision 1.4 diff -u -r1.4 Cache.php --- Cache.php 12 Jul 2002 17:30:57 -0000 1.4 +++ Cache.php 1 Aug 2002 19:55:11 -0000 @@ -249,6 +250,21 @@ return $this->container->getUserdata($id, $group); } // end func getUserdata + + /** + * Returns the exiration date of a cached data set. + * + * @param string dataset ID + * @param string cache group + * @return integer exiration date + * @access public + */ + function getExpires($id, $group = 'default') { + if (!$this->caching) + return -1; + + return $this->container->getExpires($id, $group); + } // end func getExpires /** * Removes the specified dataset from the cache. Index: Container.php =================================================================== RCS file: /repository/pear/Cache/Container.php,v retrieving revision 1.3 diff -u -r1.3 Container.php --- Container.php 12 Jul 2002 17:30:57 -0000 1.3 +++ Container.php 1 Aug 2002 19:55:11 -0000 @@ -176,6 +177,29 @@ } // end func getUserdata /** + * Return the expiration date of a cached data set. + * + * @param string dataset ID + * @param string cache group + * @return integer expiration date + * @access public + */ + function getExpires($id, $group) { + if ($this->preload) { + if ($this->id != $id || $this->group != $group) + $this->preload($id, $group); + if ($this->unknown) + return FALSE; + return $this->expires; + } else { + if (!$this->isCached($id, $group)) + return FALSE; + list ($expires, , ) = $this->fetch($id, $group); + return $expires; + } + } // end func getExpires + + /** * Checks if a dataset is expired. * * @param string dataset ID @@ -185,28 +209,16 @@ * @access public */ function isExpired($id, $group, $max_age) { - if ($this->preload) { - if ($this->id != $id || $this->group != $group) - $this->preload($id, $group); - - if ($this->unknown) - return false; - } else { - // check if at all it is cached - if (!$this->isCached($id, $group)) - return false; - - // I'm lazy... - list($this->expires, , ) = $this->fetch($id, $group); - } + $expires = $this->getExpires($id, $group); + if ($expires === FALSE) + return FALSE; // endless - if (0 == $this->expires) + if (0 == $expires) return false; // you feel fine, Ulf? - if ($expired = ($this->expires <= time() || ($max_age && ($this->expires <= $max_age))) ) { - + if ($expired = ($expires <= time() || ($max_age && ($expires <= $max_age))) ) { $this->remove($id, $group); $this->flushPreload(); }