Skip to content

Commit

Permalink
Merge branch '3.0' into 3.0-new-redis
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/actions/ci-prepare/action.yml
#	.github/workflows/ci.yml
#	.github/workflows/phpcs.yml
#	.github/workflows/phpstan.yml
#	.github/workflows/rector.yml
#	src/Cache/Handler/Redis.php
  • Loading branch information
NHZEX committed Apr 9, 2024
2 parents 347d0e5 + f687b08 commit 7b796c5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
echo "REPOSITORY_OWNER=${REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
mkdir -p /tmp/base_cache/composer
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/composer
key: ${{ runner.os }}-composer-${{ env.IMAGE_VERSION }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-swoole-cli-${{ matrix.swoole-cli }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down Expand Up @@ -338,7 +338,7 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ env.php-versions }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down Expand Up @@ -479,7 +479,7 @@ jobs:
"dir=$CacheDir" >> $env:GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache vendor
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ env.PHP_VERSION }}-${{ env.SWOOLE_VERSION }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/daily-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
strategy:
matrix:
image:
- {tag: php8.3-swoole-5.1, version: 5.1-php8.3}
- {tag: php8.2-swoole-5.1, version: 5.1-php8.2}
- {tag: php8.1-swoole-5.1, version: 5.1-php8.1}
- {tag: php8.2-swoole-5.0, version: 5.0-php8.2}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/daily-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
ref: "3.0"
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/composer
key: ${{ runner.os }}-daily-test-3.0-composer-${{ matrix.php }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
with:
ref: "2.1"
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/composer
key: ${{ runner.os }}-daily-test-2.1-composer-${{ matrix.php }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
mkdir -p /tmp/base_cache/phpcsfixer
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/composer
key: ${{ runner.os }}-composer-${{ env.IMAGE_VERSION }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand All @@ -42,7 +42,7 @@ jobs:
${{ runner.os }}-composer-
- name: Cache phpcsfixer
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/phpcsfixer
key: ${{ runner.os }}-phpcsfixer-${{ env.IMAGE_VERSION }}-${{ hashFiles('*/.php-cs-fixer.php') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
mkdir -p /tmp/base_cache/phpstan
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/composer
key: ${{ runner.os }}-composer-${{ env.IMAGE_VERSION }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand All @@ -46,7 +46,7 @@ jobs:
${{ runner.os }}-composer-
- name: Cache phpstan
uses: actions/cache@v3
uses: actions/cache@v4
if: ${{ false }}
with:
path: /tmp/base_cache/phpstan
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
mkdir -p /tmp/base_cache/rector
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/composer
key: ${{ runner.os }}-composer-${{ env.IMAGE_VERSION }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
echo "test_prepared=1" >> $GITHUB_ENV
- name: Cache Rector
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/base_cache/rector
key: ${{ runner.os }}-rector-${{ env.IMAGE_VERSION }}-${{ github.run_id }}
Expand Down
40 changes: 40 additions & 0 deletions tests/unit/Component/Tests/CacheRedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,50 @@

namespace Imi\Test\Component\Tests;

use Imi\Bean\BeanFactory;
use Imi\Cache\Handler\Redis;
use PHPUnit\Framework\Assert;

/**
* @testdox Cache Redis Handler
*/
class CacheRedisTest extends BaseCacheTestCase
{
protected string $cacheName = 'redis';

public function testMultipleWithPrefix(): void
{
$cache = BeanFactory::newInstance(Redis::class, [
'poolName' => 'redis_test',
'prefix' => 'imi-test:',
'formatHandlerClass' => \Imi\Util\Format\Json::class,
]);

$value = bin2hex(random_bytes(8));
$values = [
'k1' => 'v1' . $value,
'k2' => 'v2' . $value,
'k3' => 'v3' . $value,
];
Assert::assertTrue($cache->setMultiple($values));
$getValues = $cache->getMultiple([0 => 'k1', 2 => 'k2', 'A' => 'k3']);
Assert::assertEquals($values, $getValues);

$this->go(static function () use ($cache): void {
$value = bin2hex(random_bytes(8));

$values = [
'k1' => 'v1' . $value,
'k2' => 'v2' . $value,
];
Assert::assertTrue($cache->setMultiple($values, 1));
$getValues = $cache->getMultiple(array_keys_string($values));
Assert::assertEquals($values, $getValues);
sleep(2);
Assert::assertEquals([
'k1' => 'none',
'k2' => 'none',
], $cache->getMultiple(array_keys_string($values), 'none'));
}, null, 3);
}
}

0 comments on commit 7b796c5

Please sign in to comment.