Skip to content

Conversation

dg
Copy link
Member

@dg dg commented Sep 28, 2016

Cache file is ordinary PHP file.

@dg dg force-pushed the caching branch 2 times, most recently from 1581a88 to 59edb76 Compare September 28, 2016 20:48
@JanTvrdik
Copy link
Contributor

Good idea, I'll review the implementation in the morning



/**
* @return string
Copy link
Contributor

@JanTvrdik JanTvrdik Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be @return array (or @return mixed in theory, as it may be overridden to return anything that is serializable, but i like @return array more.

/** @deprecated */
public function setCacheStorage(Nette\Caching\IStorage $storage)
{
trigger_error(__METHOD__ . '() is deprecated; use setTempDirectory() instead.', E_USER_DEPRECATED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For FileStorage instances, we may for compatibility reasons call setTempDirectory with $storage->dir (private, so minor hacking would be required).

For other storages, exception should be thrown as RobotLoader is entirely broken and will not work unless fixed by programmer.

* @internal
*/
public function rebuildCallback()
private function refreshCache()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of refreshCache is never used

return;
}
$file = $this->getCacheFile();
$list = @include $file;
Copy link
Contributor

@JanTvrdik JanTvrdik Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe assign directly to $this->classes?
that would allow omitting $list = $this->classes and $this->classes = $list lines

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could be…

}

$file = $this->getCacheFile();
$code = '<?php return ' . var_export($this->classes, TRUE) . ';';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about better formatting (newlines after <?php, replacing path prefix with __DIR__, ...) but it's probably not worth it – it used to be totally unreadable serialized format, even default var_export formatting is a lot more readable.

@TomasVotruba
Copy link

Looks like updated. Could you review @JanTvrdik, please?

}


/**
* @return array
*/
protected function getKey()
private function getCacheFile()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return string

@dg dg force-pushed the caching branch 2 times, most recently from fe1fde2 to 7030c2f Compare October 26, 2016 20:06
@dg
Copy link
Member Author

dg commented Oct 26, 2016

@JanTvrdik thx for review

@dg dg merged commit 06a8f71 into nette:master Oct 26, 2016
@dg dg deleted the caching branch October 26, 2016 20:10
dg added a commit that referenced this pull request Oct 26, 2016
dg added a commit that referenced this pull request Jan 2, 2017
dg added a commit that referenced this pull request Jan 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants