From da4e4d77c5027fb3a687c23c9b64a7846d9c2b52 Mon Sep 17 00:00:00 2001 From: Ankit Pokhrel Date: Mon, 2 Dec 2019 21:46:15 +0100 Subject: [PATCH] Update documentation and minor cleanup --- README.md | 8 ++++++-- composer.json | 1 + src/Cache/ApcuStore.php | 2 +- src/Commands/ExpirationCommand.php | 4 ++-- tests/Cache/ApcuStoreTest.php | 5 ++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0ccef260..19cd46a0 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,10 @@ to pause, or by accident in case of a network issue or server outage. Pull the package via composer. ```shell $ composer require ankitpokhrel/tus-php + +// Use symfony-5 branch for Symfony 5+ + +$ composer require ankitpokhrel/tus-php:dev-symfony-5 ``` ### Usage @@ -78,7 +82,7 @@ This is how a simple server looks like. ```php // server.php -$server = new \TusPhp\Tus\Server('redis'); // Leave empty for file based cache +$server = new \TusPhp\Tus\Server('redis'); // Either redis, file or apcu. Leave empty for file based cache. $response = $server->serve(); $response->send(); @@ -249,7 +253,7 @@ Usage: tus:expired [] [options] Arguments: - cache-adapter Cache adapter to use, redis or file. Optional, defaults to file based cache. [default: "file"] + cache-adapter Cache adapter to use: redis, file or apcu [default: "file"] Options: -c, --config=CONFIG File to get config parameters from. diff --git a/composer.json b/composer.json index 49015daa..4e55ff23 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "symfony/http-foundation": "^3.4.11 || ^4.0" }, "require-dev": { + "ext-apcu": "*", "ext-pcntl": "*", "friendsofphp/php-cs-fixer": "^2.9", "mockery/mockery": "^1.3.0", diff --git a/src/Cache/ApcuStore.php b/src/Cache/ApcuStore.php index b4b48836..79ae0166 100644 --- a/src/Cache/ApcuStore.php +++ b/src/Cache/ApcuStore.php @@ -7,7 +7,6 @@ class ApcuStore extends AbstractCache { - /** * {@inheritDoc} */ @@ -58,6 +57,7 @@ public function delete(string $key): bool public function keys(): array { $iterator = new APCUIterator('/^' . preg_quote($this->getPrefix()) . '.*$/', APC_ITER_KEY); + return array_column(iterator_to_array($iterator, false), 'key'); } diff --git a/src/Commands/ExpirationCommand.php b/src/Commands/ExpirationCommand.php index c47eeb4a..b0cdea44 100644 --- a/src/Commands/ExpirationCommand.php +++ b/src/Commands/ExpirationCommand.php @@ -23,11 +23,11 @@ protected function configure() $this ->setName('tus:expired') ->setDescription('Remove expired uploads.') - ->setHelp('Deletes all expired uploads to free server resources. Values can be redis or file. Defaults to file.') + ->setHelp('Deletes all expired uploads to free server resources. Values can be redis, file or apcu. Defaults to file.') ->addArgument( 'cache-adapter', InputArgument::OPTIONAL, - 'Cache adapter to use, redis or file. Optional, defaults to file based cache.', + 'Cache adapter to use: redis, file or apcu', 'file' ) ->addOption( diff --git a/tests/Cache/ApcuStoreTest.php b/tests/Cache/ApcuStoreTest.php index a4cdd4c1..2736d9d5 100644 --- a/tests/Cache/ApcuStoreTest.php +++ b/tests/Cache/ApcuStoreTest.php @@ -2,7 +2,6 @@ namespace TusPhp\Test\Cache; -use Exception; use TusPhp\Cache\ApcuStore; use PHPUnit\Framework\TestCase; @@ -11,13 +10,13 @@ */ class ApcuStoreTest extends TestCase { - /** @var boolean */ protected static $extensionLoaded; /** @var ApcuStore */ protected static $store; - + + /** @var string */ protected $checksum = '74f02d6da32082463e382f2274e85fd8eae3e81f739f8959abc91865656e3b3a'; /**