-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
# Conflicts: # src/Future.php
- Loading branch information
Showing
14 changed files
with
409 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Workbunny\WebmanSharedCache\Commands; | ||
|
||
use Symfony\Component\Console\Helper\QuestionHelper; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Question\ConfirmationQuestion; | ||
|
||
class WorkbunnyWebmanSharedCacheEnable extends AbstractCommand | ||
{ | ||
protected static string $defaultName = 'workbunny:shared-cache-enable'; | ||
protected static string $defaultDescription = 'Enable APCu cache with specified settings. '; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setDescription('Enable APCu cache with specified settings.') | ||
->addOption('file', 'f', InputOption::VALUE_REQUIRED, 'Specify configuration name', 'apcu-cache.ini') | ||
->addOption('target', 't', InputOption::VALUE_REQUIRED, 'Specify target location', '/usr/local/etc/php/conf.d') | ||
->addOption('size', 'si', InputOption::VALUE_REQUIRED, 'Configure apcu.shm_size', '1024M') | ||
->addOption('segments', 'se', InputOption::VALUE_REQUIRED, 'Configure apcu.shm_segments', 1) | ||
->addOption('mmap', 'm', InputOption::VALUE_REQUIRED, 'Configure apcu.mmap_file_mask', '') | ||
->addOption('gc_ttl', 'gc', InputOption::VALUE_REQUIRED, 'Configure apcu.gc_ttl', 3600); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$fileName = $input->getOption('file'); | ||
$target = $input->getOption('target'); | ||
$shmSize = $input->getOption('size'); | ||
$shmSegments = $input->getOption('segments'); | ||
$mmapFileMask = $input->getOption('mmap'); | ||
$gcTtl = $input->getOption('gc_ttl'); | ||
|
||
if (!is_dir($target)) { | ||
return $this->error($output, "Target directory does not exist: $target. "); | ||
} | ||
$configContent = <<<EOF | ||
apc.enabled=1 | ||
apc.enable_cli=1 | ||
apc.shm_segments=$shmSegments | ||
apc.shm_size=$shmSize | ||
apc.mmap_file_mask=$mmapFileMask | ||
apc.gc_ttl=$gcTtl | ||
EOF; | ||
$filePath = "$target/$fileName"; | ||
|
||
if (file_exists($filePath)) { | ||
/** @var QuestionHelper $helper */ | ||
$helper = $this->getHelper('question'); | ||
$question = new ConfirmationQuestion("Configuration file already exists at $filePath. Overwrite? (y/N) ", false); | ||
|
||
if (!$helper->ask($input, $output, $question)) { | ||
return $this->success($output, "Operation aborted. "); | ||
} | ||
} | ||
|
||
file_put_contents($filePath, $configContent); | ||
return $this->success($output, "Configuration file created at: $filePath. "); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Workbunny\WebmanSharedCache\Commands; | ||
|
||
use Symfony\Component\Console\Helper\ProgressBar; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Workbunny\WebmanSharedCache\Cache; | ||
|
||
class WorkbunnyWebmanSharedCacheHRecycle extends AbstractCommand | ||
{ | ||
protected static string $defaultName = 'workbunny:shared-cache-hrecycle'; | ||
protected static string $defaultDescription = 'Manually recycle expired hashKeys. '; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this->setName(static::$defaultName)->setDescription(static::$defaultDescription); | ||
$this->addOption('key', 'k', InputOption::VALUE_OPTIONAL, 'Cache Key. '); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$key = $input->getOption('key'); | ||
if ($key) { | ||
Cache::HRecycle($key); | ||
} else { | ||
$progressBar = new ProgressBar($output); | ||
$progressBar->start(); | ||
$keys = Cache::Keys(); | ||
$progressBar->setMaxSteps(count($keys)); | ||
foreach ($keys as $key) { | ||
Cache::HRecycle($key); | ||
$progressBar->advance(); | ||
} | ||
$progressBar->finish(); | ||
} | ||
return $this->success($output, 'HRecycle Success. '); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.