1 | <?php |
||
6 | class SizeRestrictedPackageCache implements PackageCache { |
||
7 | |||
8 | protected $cacheSize; |
||
9 | protected $baseDir; |
||
10 | |||
11 | /** |
||
12 | * Set the maximum number of items that will be stored in the package cache. |
||
13 | * |
||
14 | * If null, items will never be deleted. If set, cache entries will be touched whenever they are accessed, |
||
15 | * and the least-recently-access items will be deleted. |
||
16 | * |
||
17 | * @param int $cacheSize the number of package files to keep. |
||
18 | */ |
||
19 | public function setCacheSize($cacheSize) { |
||
22 | |||
23 | /** |
||
24 | * The base directory to store cached packages in. |
||
25 | * The files will be stored in a subdirectory named after the identifier. |
||
26 | * If base directory isn't set, the getPackageFilename() won't run. |
||
27 | * |
||
28 | * @param string $baseDir The base directory |
||
29 | */ |
||
30 | public function setBaseDir($baseDir) { |
||
33 | |||
34 | /** |
||
35 | * Return the filename of the generated package, retrieving from cache or generating as necessary |
||
36 | * |
||
37 | * @param \PackageGenerator $generator The generator to use to create cache entries. |
||
38 | * @param string $identifier A unique identifier for the generator; used to partition the cache |
||
39 | * @param string $sha The SHA of the commit to be deployed |
||
40 | * @param string $repositoryDir The directory where the repository resides |
||
41 | * @param \DeploynautLogFile $log The log to write status output to, including package-generation commands |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | public function getPackageFilename( |
||
86 | |||
87 | /** |
||
88 | * Take the identifier an make it safe to use as a directory name. |
||
89 | * |
||
90 | * @param string $identifier The unsanitised directory name. |
||
91 | */ |
||
92 | protected function sanitiseDirName($identifier) { |
||
96 | |||
97 | /** |
||
98 | * Delete items in this directory until the number of items is <= $count. |
||
99 | * Delete the oldest files first. |
||
100 | * |
||
101 | * @param string $dir The directory to remove items from |
||
102 | * @param int $count The maximum number of .tar.gz files that can appear in that directory |
||
103 | * @param \DeploynautLogFile $log The log to send removal status messages to |
||
104 | */ |
||
105 | protected function reduceDirSizeTo($dir, $count, \DeploynautLogFile $log) { |
||
118 | } |
||
119 |