Skip to content

Commit

Permalink
Merge pull request #110 from php-annotations/107-introduce-cache-form…
Browse files Browse the repository at this point in the history
…at-versioning

Introduce cache versioning
  • Loading branch information
Alexander Obuhovich committed Feb 14, 2016
2 parents c9072aa + 38d3365 commit 99b4071
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/annotations/AnnotationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class AnnotationManager
{
const CACHE_FORMAT_VERSION = 3;

const MEMBER_CLASS = 'class';

const MEMBER_PROPERTY = 'property';
Expand Down Expand Up @@ -193,7 +195,8 @@ protected function getAnnotationFile($path)
$code = $this->getParser()->parseFile($path);
$data = eval($code);
} else {
$key = basename($path) . '-' . sprintf('%x', crc32($path . $this->_cacheSeed));
$checksum = crc32($path . ':' . $this->_cacheSeed . ':' . self::CACHE_FORMAT_VERSION);
$key = basename($path) . '-' . sprintf('%x', $checksum);

if (($this->cache->exists($key) === false) || (filemtime($path) > $this->cache->getTimestamp($key))) {
$code = $this->getParser()->parseFile($path);
Expand Down

0 comments on commit 99b4071

Please sign in to comment.