PHP Class SizeRestrictedPackageCache

Inheritance: implements PackageCache
Mostrar archivo Open project: silverstripe/deploynaut

Protected Properties

Property Type Description
$baseDir
$cacheSize

Public Methods

Method Description
getPackageFilename ( PackageGenerator $generator, string $identifier, string $sha, string $repositoryDir, DeploynautLogFile $log ) : string Return the filename of the generated package, retrieving from cache or generating as necessary
setBaseDir ( string $baseDir ) The base directory to store cached packages in.
setCacheSize ( integer $cacheSize ) Set the maximum number of items that will be stored in the package cache.

Protected Methods

Method Description
reduceDirSizeTo ( string $dir, integer $count, DeploynautLogFile $log ) Delete items in this directory until the number of items is <= $count.
sanitiseDirName ( string $identifier ) Take the identifier an make it safe to use as a directory name.

Method Details

getPackageFilename() public method

Return the filename of the generated package, retrieving from cache or generating as necessary
public getPackageFilename ( PackageGenerator $generator, string $identifier, string $sha, string $repositoryDir, DeploynautLogFile $log ) : string
$generator PackageGenerator The generator to use to create cache entries.
$identifier string A unique identifier for the generator; used to partition the cache
$sha string The SHA of the commit to be deployed
$repositoryDir string The directory where the repository resides
$log DeploynautLogFile The log to write status output to, including package-generation commands
return string

reduceDirSizeTo() protected method

Delete the oldest files first.
protected reduceDirSizeTo ( string $dir, integer $count, DeploynautLogFile $log )
$dir string The directory to remove items from
$count integer The maximum number of .tar.gz files that can appear in that directory
$log DeploynautLogFile The log to send removal status messages to

sanitiseDirName() protected method

Take the identifier an make it safe to use as a directory name.
protected sanitiseDirName ( string $identifier )
$identifier string The unsanitised directory name.

setBaseDir() public method

The files will be stored in a subdirectory named after the identifier. If base directory isn't set, the getPackageFilename() won't run.
public setBaseDir ( string $baseDir )
$baseDir string The base directory

setCacheSize() public method

If null, items will never be deleted. If set, cache entries will be touched whenever they are accessed, and the least-recently-access items will be deleted.
public setCacheSize ( integer $cacheSize )
$cacheSize integer the number of package files to keep.

Property Details

$baseDir protected_oe property

protected $baseDir

$cacheSize protected_oe property

protected $cacheSize