public function read($hash, $namespace = null)
    {
        $data = false;

        // Check namespace first
        if (!is_null($namespace) && is_null($hash)) {
            $data = $this->Database->fetch("
                SELECT SQL_NO_CACHE *
                FROM `tbl_cache`
                WHERE `namespace` = '$namespace'
                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)
            ");
        }

        // Then check hash
        if (!is_null($hash)) {
            $data = $this->Database->fetchRow(0, "
                SELECT SQL_NO_CACHE *
                FROM `tbl_cache`
                WHERE `hash` = '$hash'
                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)
                LIMIT 1
            ");
        }

        // If the data exists, see if it's still valid
        if ($data) {
            if (!$data['data'] = Cacheable::decompressData($data['data'])) {
                $this->delete($hash, $namespace);

                return false;
            }

            return $data;
        }

        $this->delete(null, $namespace);

        return false;
    }
public function read($hash, $namespace = null)
    {
        $data = false;

        // Check namespace first
        if (!is_null($namespace) && is_null($hash)) {
            $data = $this->Database->fetch("
                SELECT SQL_NO_CACHE *
                FROM `tbl_cache`
                WHERE `namespace` = '$namespace'
                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)
            ");
        }

        // Then check hash
        if (!is_null($hash)) {
            $data = $this->Database->fetchRow(0, "
                SELECT SQL_NO_CACHE *
                FROM `tbl_cache`
                WHERE `hash` = '$hash'
                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)
                LIMIT 1
            ");
        }

        // If the data exists, see if it's still valid
        if ($data) {
            if (!$data['data'] = Cacheable::decompressData($data['data'])) {
                $this->delete($hash, $namespace);

                return false;
            }

            return $data;
        }

        $this->delete(null, $namespace);

        return false;
    }
public function read ( $ hash , $ namespace = null ) { $ data = false ; // Check namespace first if ( ! is_null ( $ namespace ) && is_null ( $ hash ) ) { $ data = $ this -> Database -> fetch ( "
                SELECT SQL_NO_CACHE *
                FROM `tbl_cache`
                WHERE `namespace` = '$namespace'
                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)
            " ) ; } // Then check hash if ( ! is_null ( $ hash ) ) { $ data = $ this -> Database -> fetchRow ( 0 , "
                SELECT SQL_NO_CACHE *
                FROM `tbl_cache`
                WHERE `hash` = '$hash'
                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)
                LIMIT 1
            " ) ; } // If the data exists, see if it's still valid if ( $ data ) { if ( ! $ data [ 'data' ] = Cacheable :: decompressData ( $ data [ 'data' ] ) ) { $ this -> delete ( $ hash , $ namespace ) ; return false ; } return $ data ; } $ this -> delete ( null , $ namespace ) ; return false ; }
Given the hash of a some data, check to see whether it exists in
`tbl_cache`. If no cached object is found, this function will return
false, otherwise the cached object will be returned as an array.

@param string $hash
The hash of the Cached object, as defined by the user
@param string $namespace
The namespace allows a group of data to be retrieved at once
@return array|boolean
An associative array of the cached object including the creation time,
expiry time, the hash and the data. If the object is not found, false will
be returned.
Given the hash of a some data check to see whether it exists in tbl_cache . If no cached object is found this function will return false otherwise the cached object will be returned as an array .