Skip to content

Commit 5a98b2d

Browse files
committed
Fixed some typos & added DocBlock & updated Memstatic Driver
1 parent c78df57 commit 5a98b2d

File tree

4 files changed

+7
-37
lines changed

4 files changed

+7
-37
lines changed

lib/Phpfastcache/Drivers/Cassandra/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getHelp(): string
6060
To install the php Cassandra extension via Pecl:
6161
<code>sudo pecl install cassandra</code>
6262
More information on: https://github.com/datastax/php-driver
63-
Please not that this repository only provide php stubs and C/C++ sources, it does NOT provide php client.
63+
Please note that this repository only provide php stubs and C/C++ sources, it does NOT provide php client.
6464
</p>
6565
HELP;
6666
}

lib/Phpfastcache/Drivers/Memstatic/Driver.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ protected function driverConnect(): bool
7373
*/
7474
protected function driverRead(CacheItemInterface $item)
7575
{
76-
$key = md5($item->getKey());
77-
if (isset($this->staticStack[$key])) {
78-
return $this->staticStack[$key];
79-
}
80-
return null;
76+
return $this->staticStack[$item->getKey()] ?? null;
8177
}
8278

8379
/**
@@ -91,7 +87,7 @@ protected function driverWrite(CacheItemInterface $item): bool
9187
* Check for Cross-Driver type confusion
9288
*/
9389
if ($item instanceof Item) {
94-
$this->staticStack[md5($item->getKey())] = $this->driverPreWrap($item);
90+
$this->staticStack[$item->getKey()] = $this->driverPreWrap($item);
9591
return true;
9692
}
9793

@@ -109,7 +105,7 @@ protected function driverDelete(CacheItemInterface $item): bool
109105
* Check for Cross-Driver type confusion
110106
*/
111107
if ($item instanceof Item) {
112-
$key = md5($item->getKey());
108+
$key = $item->getKey();
113109
if (isset($this->staticStack[$key])) {
114110
unset($this->staticStack[$key]);
115111
return true;
@@ -135,4 +131,4 @@ protected function driverClear(): bool
135131
$this->staticStack = [];
136132
return true;
137133
}
138-
}
134+
}

lib/Phpfastcache/Helper/Psr16Adapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ public function has($key): bool
232232

233233
/**
234234
* @return ExtendedCacheItemPoolInterface
235+
* @internal
235236
*/
236237
public function getInternalCacheInstance(): ExtendedCacheItemPoolInterface
237238
{

tests/Memstatic.test.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,6 @@
1212
require_once __DIR__ . '/../vendor/autoload.php';
1313
$testHelper = new TestHelper('Memstatic driver');
1414
$cacheInstance = CacheManager::getInstance('Memstatic');
15-
$cacheKey = 'testItem';
16-
$randomStr = str_shuffle(sha1(uniqid('pfc', true) . mt_rand(100, 10000)));
17-
$testHelper->printText("Random-generated cache value for key '{$cacheKey}': {$randomStr}");
18-
19-
$item = $cacheInstance->getItem($cacheKey);
20-
$item->set($randomStr)->expiresAfter(60);
21-
$cacheInstance->save($item);
22-
$cacheInstance->detachAllItems();
23-
unset($item);
24-
25-
$item = $cacheInstance->getItem($cacheKey);
26-
27-
$cacheResult = $cacheInstance->getItem($cacheKey)->get();
28-
29-
if ($cacheResult === $randomStr) {
30-
$testHelper->assertPass("The cache key value match, got expected value '{$cacheResult}'");
31-
} else {
32-
$testHelper->assertFail("The cache key value match expected value '{$randomStr}', got '{$cacheResult}'");
33-
}
34-
$testHelper->printText('Clearing the whole cache to test item cleaning...');
35-
$cacheInstance->clear();
36-
$cacheResult = ($cacheInstance->getItem($cacheKey)->isHit() === false && $cacheInstance->getItem($cacheKey)->get() === null);
37-
38-
if ($cacheResult === true) {
39-
$testHelper->assertPass('The cache item is null as expected');
40-
} else {
41-
$testHelper->assertFail('The cache is not null');
42-
}
4315

16+
$testHelper->runCRUDTests($cacheInstance);
4417
$testHelper->terminateTest();

0 commit comments

Comments
 (0)