Location: PHPKode > projects > Blackwolf CMF > projectBlackWolf/lib/Cache/Object.class.php
<?php

/* Please see the README and LICENSE files. */

/**
 * Represents something that can be cached
 */
class Cache_Object {

    protected $_data;
    protected $name;
    protected $date_created;
    protected $max_age;

    public function __construct($name, $data, $max_age) {
        $this->name = $name;
        $this->data = $this->set_data($data);
        $this->max_age = $max_age;
        $this->date_created = time();
    }

    protected function encode_data() {
        $this->_data = gzcompress(serialize($this->_data));
    }

    protected function decode_data($data) {
        return unserialize(gzuncompress($this->_data));
    }

    public function __get($name) {
        switch ($name) {
            case "data":
                return $this->decode_data($this->_data);
                break;
            default:
                if (property_exists($this, $name)) {
                    return $this->$name;
                }
                break;
        }
    }
}

?>
Return current item: Blackwolf CMF