Skip to content

Commit

Permalink
for php 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
yupmin committed Jan 9, 2023
1 parent 5abe8cc commit e7b7a47
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']
php-version: ['8.0', '8.1', '8.2']
env:
extensions: apcu, bcmath, gd, redis-phpredis/phpredis@5.3.5, sqlite, pdo_sqlite
steps:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Requirement

* PHP 7.4, 8.0, 8.1, 8.2
* PHP 8.0, 8.1, 8.2
* Modern PHP

### About Phystrix
Expand All @@ -22,7 +22,7 @@ In case of a service failing way too often, to not make the situation worse, Phy

### Differences from [older version(upwork/phystrix)](https://github.com/upwork/phystrix)

* Use PHP 7.4 above
* Use PHP 8.0 above
* Change from 'Zend DI' to 'PSR DI', DI is optional. (for using Your framework)
* Add [phystrix dashboard](https://github.com/upwork/phystrix-dashboard) library, and fix more.
* Add Libraries of APCU
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
}
},
"require": {
"php": ">=7.4",
"php": ">=8.0",
"ext-json": "*",
"ext-apcu": "*",
"psr/container": "^1.0|^2.0",
"psr/simple-cache": "^1.0",
"laminas/laminas-config": "^3.5"
"psr/container": "^1.0",
"psr/simple-cache": "^3.0",
"laminas/laminas-config": "^3.8"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand Down
22 changes: 14 additions & 8 deletions src/RequestCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,24 @@ class RequestCache implements CacheInterface
{
protected array $storage = [];

public function clear()
public function clear(): bool
{
unset($this->storage);
$this->storage = [];

return true;
}

public function delete($key)
public function delete(string $key): bool
{
if ($this->has($key)) {
unset($this->storage[$key]);
}

return true;
}

public function get($key, $default = null)
public function get(string $key, mixed $default = null): mixed
{
if ($this->has($key)) {
return $this->storage[$key];
Expand All @@ -54,27 +58,29 @@ public function get($key, $default = null)
return $default;
}

public function set($key, $value, $ttl = null)
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool
{
$this->storage[$key] = $value;

return true;
}

public function has($key)
public function has(string $key): bool
{
return array_key_exists($key, $this->storage);
}

public function getMultiple($keys, $default = null)
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
throw new Exception('Not supported');
}

public function setMultiple($values, $ttl = null)
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool
{
throw new Exception('Not supported');
}

public function deleteMultiple($keys)
public function deleteMultiple(iterable $keys): bool
{
throw new Exception('Not supported');
}
Expand Down

0 comments on commit e7b7a47

Please sign in to comment.