PHPAV icon indicating copy to clipboard operation
PHPAV copied to clipboard

Cache system

Open soullivaneuh opened this issue 8 years ago • 2 comments

It would be great to have a cache system.

If a file was analysed before and didn't change since this time, we don't have to analyse it.

Also a --no-cache option must be added to get rid of this system.

Question: Where to store the cache? On the project folder (where the phpav command is run)? On a home special directory (e.g.: ~/.phpav/cache)? I think the second option would be better.

Composer and php-cs-fixer cache system would be a good inspiration.

We can store the cache with this way:

  • Key: The md5 of the file to compare with the queued one.
  • Content: A serialization of a class containing analyse information (infected, not infected, why...)

This will allows to increase the speed of the script.

soullivaneuh avatar Jan 04 '17 13:01 soullivaneuh

We can also use a cache system like the Symfony cache component.

It provides multiple cache type (filesystem, doctrine etc) and allows configuration.

The problem is PHP 5.5 is required. But this can be solved thanks to #30.

soullivaneuh avatar Jan 04 '17 14:01 soullivaneuh

Also we must not forget about the signature of the cache. The cache must be invalidated if the version of phpav is different.

Example: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/925a5cadb005bef14e0c806fc19bf902e4f80f65/src/Cache/Cache.php#L117-L121

soullivaneuh avatar Jan 04 '17 14:01 soullivaneuh