diff --git a/README.md b/README.md index 27ddd04..9823174 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ docker build . -t cm-cache-backend-redis Then start a Redis server, install Composer dependencies and run tests like so: ```shell - docker run --rm -d -p 6379 --name cm-cache-backend-redis redis + docker run --rm -d -p 6379 --name cm-cache-backend-redis redis --maxmemory 20m --maxmemory-policy noeviction cm-cache-backend-redis composer install cm-cache-backend-redis composer run-script test cm-cache-backend-redis composer run-script php-cs-fixer -- --dry-run diff --git a/composer.json b/composer.json index 4d2e3ea..e6ec477 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ }, "scripts": { "test": "vendor/bin/phpunit tests", + "test-performance": "PERFORMANCE=1 vendor/bin/phpunit tests --filter testLargePayloadLoop", "php-cs-fixer": "vendor/bin/php-cs-fixer fix --diff" } } diff --git a/tests/RedisBackendTest.php b/tests/RedisBackendTest.php index ad9c6e0..7b74fd0 100644 --- a/tests/RedisBackendTest.php +++ b/tests/RedisBackendTest.php @@ -88,6 +88,20 @@ public function testCompression(): void $this->assertTrue($this->_instance->load('long') == $longString); } + public function testLargePayloadLoop() + { + if (getenv('PERFORMANCE')) { + $longString = file_get_contents(__FILE__); + $tags = ['one','two','three','four','five','six','seven','eight','nine','ten']; + for ($i = 0; $i < 1000; $i++) { + $this->_instance->save($longString, $tags[$i % 10], $tags); + } + $this->assertTrue(true); + } else { + $this->markTestSkipped('Skipping large payload test'); + } + } + public function testExpiredCleanup(): void { $this->assertTrue($this->_instance->clean());