src/main/php/annotation/AnnotationCache.php
public static function start(callable $readCache, callable $storeCache)
    {
        self::$annotations = $readCache();
        if (!is_array(self::$annotations)) {
            self::flush();
            throw new \RuntimeException('Cached annotation data is not an array');
        }

        self::$unserialized = [];
        self::$cacheChanged = false;
        self::$storeCache   = $storeCache;
        register_shutdown_function([__CLASS__, '__shutdown']);
    }
public static function start(callable $readCache, callable $storeCache)
    {
        self::$annotations = $readCache();
        if (!is_array(self::$annotations)) {
            self::flush();
            throw new \RuntimeException('Cached annotation data is not an array');
        }

        self::$unserialized = [];
        self::$cacheChanged = false;
        self::$storeCache   = $storeCache;
        register_shutdown_function([__CLASS__, '__shutdown']);
    }
public static function start ( callable $ readCache , callable $ storeCache ) { self :: $ annotations = $ readCache ( ) ; if ( ! is_array ( self :: $ annotations ) ) { self :: flush ( ) ; throw new \ RuntimeException ( 'Cached annotation data is not an array' ) ; } self :: $ unserialized = [ ] ; self :: $ cacheChanged = false ; self :: $ storeCache = $ storeCache ; register_shutdown_function ( [ __CLASS__ , '__shutdown' ] ) ; }
start annotation cache with given cache storage logic

Calling this method will also flush the cache. If this method is never
called the annotation cache will not be persistent but only last as long
as the current request is running.

The $readCache closure must return the stored annotation data. If no such
data is present it must return null. In case the stored annotation data
can't be unserialized into an array a \RuntimeException will be thrown.

The $storeCache closure must store passed annotation data. It doesn't
need to take care about serialization, as it already receives a
serialized representation.

A possible implementation for the file cache would look like this:
<code>
AnnotationCache::start(
function() use($cacheFile)
{
if (file_exists($cacheFile)) {
return unserialize(file_get_contents($cacheFile));
}

return [];
},
function(array $annotationData) use($cacheFile)
{
file_put_contents($cacheFile, serialize($annotationData));
}
);
</code>

@param   callable  $readCache   function which can return cached annotation data
@param   callable  $storeCache  function which takes cached annotation data and stores it
@throws  \RuntimeException
@since   3.0.0
start annotation cache with given cache storage logic