public function cacheObject($key, $object, $timeoutSeconds = -1) {

        $cache = HttpSession::instance()->getValue("__SESSION_CACHED_ITEMS");
        if (!is_array($cache)) {
            $cache = array();
        }

        $cache[$key] = $object;

        HttpSession::instance()->setValue("__SESSION_CACHED_ITEMS", $cache);


        if ($timeoutSeconds > 0) {
            $timeouts = HttpSession::instance()->getValue("__SESSION_CACHE_TIMEOUTS");
            if (!is_array($timeouts)) {
                $timeouts = array();
            }

            $dateTime = new \DateTime();
            $dateTime->add(new \DateInterval("PT" . $timeoutSeconds . "S"));
            $timeouts[$key] = $dateTime->format("d/m/Y H:i:s");

            HttpSession::instance()->setValue("__SESSION_CACHE_TIMEOUTS", $timeouts);
        }


    }
public function cacheObject($key, $object, $timeoutSeconds = -1) {

        $cache = HttpSession::instance()->getValue("__SESSION_CACHED_ITEMS");
        if (!is_array($cache)) {
            $cache = array();
        }

        $cache[$key] = $object;

        HttpSession::instance()->setValue("__SESSION_CACHED_ITEMS", $cache);


        if ($timeoutSeconds > 0) {
            $timeouts = HttpSession::instance()->getValue("__SESSION_CACHE_TIMEOUTS");
            if (!is_array($timeouts)) {
                $timeouts = array();
            }

            $dateTime = new \DateTime();
            $dateTime->add(new \DateInterval("PT" . $timeoutSeconds . "S"));
            $timeouts[$key] = $dateTime->format("d/m/Y H:i:s");

            HttpSession::instance()->setValue("__SESSION_CACHE_TIMEOUTS", $timeouts);
        }


    }
public function cacheObject ( $ key , $ object , $ timeoutSeconds = - 1 ) { $ cache = HttpSession :: instance ( ) -> getValue ( "__SESSION_CACHED_ITEMS" ) ; if ( ! is_array ( $ cache ) ) { $ cache = array ( ) ; } $ cache [ $ key ] = $ object ; HttpSession :: instance ( ) -> setValue ( "__SESSION_CACHED_ITEMS" , $ cache ) ; if ( $ timeoutSeconds > 0 ) { $ timeouts = HttpSession :: instance ( ) -> getValue ( "__SESSION_CACHE_TIMEOUTS" ) ; if ( ! is_array ( $ timeouts ) ) { $ timeouts = array ( ) ; } $ dateTime = new \ DateTime ( ) ; $ dateTime -> add ( new \ DateInterval ( "PT" . $ timeoutSeconds . "S" ) ) ; $ timeouts [ $ key ] = $ dateTime -> format ( "d/m/Y H:i:s" ) ; HttpSession :: instance ( ) -> setValue ( "__SESSION_CACHE_TIMEOUTS" , $ timeouts ) ; } }
Cache an object with a key and an optional timeout in seconds.

@param $key
@param $object
Cache an object with a key and an optional timeout in seconds .