public function cacheVal($value, $id = null) {
        if ($id == null) {
            if (is_object($value))
                $id = $this->getIDfromOjb($value);

            if ($id == null && $this->getConfig('debug')) {
                echo "no caching key";
                return $value;
            }
        }

        $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id);
        $cachetime = $this->getConfig('cacheTime');

        if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) {
            $ser = file_get_contents($cachefile);
            $val = bzdecompress(unserialize($ser));
            return $val;
        } else {
            $ser = bzcompress(serialize($value));
            file_put_contents($cachefile, $ser);
            return $value;
        }

        if ($this->getConfig('debug'))
            echo "no caching";
    }