Skip to content

Commit

Permalink
feat: use Redis initialization logic from symfony/cache (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond authored Oct 28, 2024
1 parent 688a2ae commit 756f7a3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 306 deletions.
53 changes: 4 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,23 @@ on:
env:
REDIS_HOST1: localhost:16379
REDIS_HOST2: 127.0.0.1:16379
REDIS_CLUSTER_HOSTS: localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005
REDIS_SENTINEL_HOST: 'localhost:26379'
REDIS_SENTINEL_SERVICE: redis_sentinel

jobs:
tests:
name: PHP ${{ matrix.php }} - ${{ matrix.deps }}
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.0, 8.1, 8.2]
php: [8.1, 8.2, 8.3, 8.4]
deps: [highest]
include:
- php: 8.0
- php: 8.1
deps: lowest
services:
redis:
image: redis:6.0.0
image: redis:6
ports:
- 16379:6379
redis-cluster:
image: grokzen/redis-cluster:latest
ports:
- 7000:7000
- 7001:7001
- 7002:7002
- 7003:7003
- 7004:7004
- 7005:7005
- 7006:7006
env:
STANDALONE: 1
redis-sentinel:
image: bitnami/redis-sentinel:6.0
ports:
- 26379:26379
env:
REDIS_MASTER_HOST: redis
REDIS_MASTER_SET: redis_sentinel
REDIS_SENTINEL_QUORUM: 1
steps:
- uses: zenstruck/.github@php-test-symfony
with:
Expand All @@ -60,33 +37,11 @@ jobs:
runs-on: ubuntu-latest
services:
redis:
image: redis:6.0.0
image: redis:6
ports:
- 16379:6379
redis-cluster:
image: grokzen/redis-cluster:latest
ports:
- 7000:7000
- 7001:7001
- 7002:7002
- 7003:7003
- 7004:7004
- 7005:7005
- 7006:7006
env:
STANDALONE: 1
redis-sentinel:
image: bitnami/redis-sentinel:6.0
ports:
- 26379:26379
env:
REDIS_MASTER_HOST: redis
REDIS_MASTER_SET: redis_sentinel
REDIS_SENTINEL_QUORUM: 1
steps:
- uses: zenstruck/.github@php-coverage-codecov
with:
php: 8.1

composer-validate:
uses: zenstruck/.github/.github/workflows/php-composer-validate.yml@main
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
}
],
"require": {
"php": ">=8.0",
"ext-redis": "*"
"php": ">=8.1",
"ext-redis": "*",
"symfony/cache": "^5.4|^6.0|^7.0"
},
"require-dev": {
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.5.0",
"symfony/phpunit-bridge": "^6.0",
"symfony/var-dumper": "^4.4|^5.0|^6.0"
"phpunit/phpunit": "^9.6.21",
"symfony/phpunit-bridge": "^6.0|^7.0",
"symfony/var-dumper": "^5.4|^6.0|^7.0"
},
"config": {
"preferred-install": "dist",
Expand Down
23 changes: 1 addition & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
version: '3'
services:
redis:
image: redis:6.0
image: redis:6
ports:
- 16379:6379
redis-cluster:
image: grokzen/redis-cluster:latest
ports:
- 7000:7000
- 7001:7001
- 7002:7002
- 7003:7003
- 7004:7004
- 7005:7005
- 7006:7006
environment:
- STANDALONE=1
redis-sentinel:
image: bitnami/redis-sentinel:6.0
ports:
- 26379:26379
environment:
- REDIS_MASTER_HOST=redis
- REDIS_MASTER_SET=redis_sentinel
- REDIS_SENTINEL_QUORUM=1
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ parameters:
message: "#^Cannot call method add\\(\\) on DateTime\\|false\\.$#"
count: 1
path: src/Redis/Utility/ExpiringSet.php
-
message: "#^Parameter \\#1 \\$client of class Zenstruck\\\\Redis constructor expects \\(callable\\(\\)\\: Redis\\|RedisArray\\|RedisCluster\\)\\|Redis\\|RedisArray\\|RedisCluster, bool\\|Redis\\|null given\\.$#"
count: 1
path: src/Redis.php
-
message: "#^Cannot call method multi\\(\\) on bool\\|Redis\\|RedisCluster\\|null\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function getIterator(): \Traversable

if ($client instanceof \RedisArray) {
foreach ($client->_hosts() as $host) {
yield new self($client->_instance($host));
yield new self($client->_instance($host)); // @phpstan-ignore-line
}

return;
Expand Down
Loading

0 comments on commit 756f7a3

Please sign in to comment.