Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=
REDIS_PORT=6379
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ jobs:

- name: Prepare for environment variables
run: |
cp .env.testing .env
composer dump-autoload

- name: Run Testsuite
run: vendor/bin/pest tests/ --coverage-text --colors=always --coverage-html=coverage --coverage-clover coverage.xml
env:
REDIS_HOST: 127.0.0.1
REDIS_PASSWORD:
REDIS_PORT: 6379

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
Expand Down
14 changes: 11 additions & 3 deletions src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@ public function __construct(array $config = [])
$this->type = 'string';
$this->score = 0;
$this->expire = -1;

$options = [
'parameters' => [
'password' => $config['password'] ?? getenv('REDIS_PASSWORD') ?? '',
'database' => $config['database'] ?? getenv('REDIS_DB') ?? 0,
],
];
$this->client = new Client([
'scheme' => 'tcp',
'host' => $config['host'] ?? '127.0.0.1',
'port' => $config['port'] ?? 6379,
]);
'host' => $config['host'] ?? getenv('REDIS_HOST') ?? '127.0.0.1',
'port' => $config['port'] ?? getenv('REDIS_PORT') ?? 6379,
], $options);
}

/**
* 调用predis方法.
*
* @param string $name
* @param array $arguments
*/
public function __call(string $name, array $arguments): void
Expand Down