Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c3e7563

Browse files
author
Jonathon Hill
committed
feat!: support psr/simple-cache v2 and v3
Resolves #2
1 parent 243d859 commit c3e7563

File tree

8 files changed

+406
-506
lines changed

8 files changed

+406
-506
lines changed

‎composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"require": {
4242
"php": "^7.4 || ^8.0",
4343
"dflydev/fig-cookies": "^3.0",
44-
"psr/simple-cache": "^1",
44+
"psr/simple-cache": "^2 || ^3",
4545
"psr/http-message": "^1",
4646
"psr/http-server-handler": "^1",
4747
"psr/http-server-middleware": "^1"
@@ -51,12 +51,11 @@
5151
"bramus/monolog-colored-line-formatter": "^3.0",
5252
"compwright/swoole-psr7-compat": "^2.0",
5353
"friendsofphp/php-cs-fixer": "^3.11",
54-
"kodus/file-cache": "^1.1",
54+
"kodus/file-cache": "^2",
5555
"league/flysystem": "^2.2",
5656
"matthiasmullie/scrapbook": "^1.4",
5757
"middlewares/access-log": "^2.0",
5858
"monolog/monolog": "^2.3",
59-
"odan/cache": "^0.5.0",
6059
"php-di/php-di": "^6.3",
6160
"phpstan/phpstan": "^1.8",
6261
"phpunit/phpunit": "^9.5",

‎composer.lock

Lines changed: 391 additions & 469 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎features/persistence.feature

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ Feature: Session Persistence
2020
| kodus | A |
2121
| scrapbook | B |
2222
| redis | 0 |
23-
| opcache | C |
24-
| file | D |
23+
| file | C |

‎src/Handlers/ArrayHandler.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ public function close(): bool
5353
return true;
5454
}
5555

56-
/**
57-
* @param string $id
58-
* @return string|false
59-
*/
60-
public function read($id)
56+
public function read(string $id): string|false
6157
{
6258
if (
6359
!array_key_exists($id, $this->store)
@@ -172,7 +168,7 @@ public function destroy($id): bool
172168
return true;
173169
}
174170

175-
public function gc($max_lifetime): bool
171+
public function gc($max_lifetime): int|false
176172
{
177173
$garbage = array_filter(
178174
$this->store,
@@ -192,7 +188,7 @@ function ($store) use ($max_lifetime) {
192188
unset($this->store[$session['meta']['id']]);
193189
}
194190

195-
return true;
191+
return count($garbage);
196192
}
197193

198194
public function count(): int

‎src/Handlers/FileHandler.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ public function close(): bool
5555
return true;
5656
}
5757

58-
/**
59-
* @param string $id
60-
* @return string|false
61-
*/
62-
public function read($id)
58+
public function read(string $id): string|false
6359
{
6460
if (!$this->validateId($id)) {
6561
return false;
@@ -86,7 +82,7 @@ public function destroy($id): bool
8682
return unlink($this->getFilePath($id));
8783
}
8884

89-
public function gc($maxlifetime): bool
85+
public function gc(int$maxlifetime): int|false
9086
{
9187
$files = glob($this->getFilePath('*')) ?: [];
9288

@@ -96,7 +92,7 @@ public function gc($maxlifetime): bool
9692
}
9793
}
9894

99-
return true;
95+
return count($files);
10096
}
10197

10298
public function validateId($id): bool

‎src/Handlers/Psr16Handler.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ public function close(): bool
4747
return true;
4848
}
4949

50-
/**
51-
* @param string $id
52-
* @return string|false
53-
*/
54-
public function read($id)
50+
public function read(string $id): string|false
5551
{
5652
if (!$this->store->has($id)) {
5753
return false;
@@ -94,9 +90,9 @@ public function destroy($id): bool
9490
return $this->store->delete($id);
9591
}
9692

97-
public function gc($max_lifetime): bool
93+
public function gc(int$max_lifetime): int|false
9894
{
99-
return true;
95+
return 0;
10096
}
10197

10298
/**

‎src/Handlers/ScrapbookHandler.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ public function close(): bool
6464
return true;
6565
}
6666

67-
/**
68-
* @param string $id
69-
* @return string|false
70-
*/
71-
public function read($id)
67+
public function read(string $id): string|false
7268
{
7369
$value = $this->store->get($id);
7470
if (is_string($value) || $value === false) {
@@ -130,9 +126,9 @@ public function destroy($id): bool
130126
return $this->store->delete($id);
131127
}
132128

133-
public function gc($max_lifetime): bool
129+
public function gc(int$max_lifetime): int|false
134130
{
135-
return true;
131+
return 0;
136132
}
137133

138134
/**

‎tests/behavior/PersistenceContext.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ public function sessionHandlerStoredAtLocation(string $handler, string $location
5959
$this->config->setSavePath('tcp://localhost:6379?database=0');
6060
$handler = new RedisHandler($this->config);
6161
break;
62-
case 'opcache':
63-
$cache = new \Odan\Cache\Simple\OpCache($location);
64-
$handler = new Psr16Handler($this->config, $cache);
65-
break;
6662
case 'file':
6763
$handler = new FileHandler($this->config);
6864
break;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /