getKey(); $data = $this->getSerializable(); set_transient( $key, $data, $ttl ); $this->lazy = null; $this->clean(); } else { $this->lazy = $ttl; } return $this; } /** * Commit to transient cache on object destruction */ final public function __destruct(){ if( is_int($this->lazy) ){ $this->persistIfDirty( $this->lazy, true ); } } /** * Retrieve and unserialize this object from WordPress transient cache * @return bool whether object existed in cache */ public function fetch(){ $v = $this->getVersion(); $key = 'loco_'.$this->getKey(); $data = get_transient( $key ); try { $this->setUnserialized($data); return true; } catch( InvalidArgumentException $e ){ return false; } } }