Skip to content

Commit 23349f1

Browse files
authored
Merge pull request #490 from Geolim4/final
Staticized driverName
2 parents c6bc874 + 56c45d9 commit 23349f1

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

src/phpFastCache/Core/Pool/CacheItemPoolTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ public function getItems(array $keys = [])
228228
*/
229229
public function hasItem($key)
230230
{
231-
CacheManager::$ReadHits++;
232-
233231
return $this->getItem($key)->isHit();
234232
}
235233

@@ -259,7 +257,7 @@ public function clear()
259257
public function deleteItem($key)
260258
{
261259
$item = $this->getItem($key);
262-
if ($this->hasItem($key) && $this->driverDelete($item)) {
260+
if ($item->isHit() && $this->driverDelete($item)) {
263261
$item->setHit(false);
264262
CacheManager::$WriteHits++;
265263

src/phpFastCache/Core/Pool/DriverBaseTrait.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ trait DriverBaseTrait
4242
*/
4343
protected $instance;
4444

45+
/**
46+
* @var string
47+
*/
48+
protected $driverName;
49+
4550
/**
4651
* @param $config_name
4752
* @param string $value
@@ -211,9 +216,10 @@ public function driverUnwrapMdate(array $wrapper)
211216
*/
212217
public function getDriverName()
213218
{
214-
static $driverName;
215-
216-
return ($driverName ?: $driverName = ucfirst(substr(strrchr((new \ReflectionObject($this))->getNamespaceName(), '\\'), 1)));
219+
if(!$this->driverName){
220+
$this->driverName = ucfirst(substr(strrchr((new \ReflectionObject($this))->getNamespaceName(), '\\'), 1));
221+
}
222+
return $this->driverName;
217223
}
218224

219225
/**
@@ -232,6 +238,11 @@ public function driverWriteTags(ExtendedCacheItemInterface $item)
232238
throw new phpFastCacheLogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey());
233239
}
234240

241+
if(!$item->getTags() && !$item->getRemovedTags())
242+
{
243+
return true;
244+
}
245+
235246
/**
236247
* @var $tagsItems ExtendedCacheItemInterface[]
237248
*/

src/phpFastCache/Drivers/Files/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function driverRead(CacheItemInterface $item)
9494
/**
9595
* Check for Cross-Driver type confusion
9696
*/
97-
$file_path = $this->getFilePath($item->getKey());
97+
$file_path = $this->getFilePath($item->getKey(), true);
9898
if (!file_exists($file_path)) {
9999
return null;
100100
}

tests/ReadWriteOperations.test.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,14 @@
6767
}
6868
}
6969

70+
foreach ($dirs as $dirIndex => $dir){
71+
for ($i = 1; $i <= 20; $i++)
72+
{
73+
$cacheInstanceName = 'cacheInstance' . $i;
74+
75+
$testHelper->printText(sprintf('Clearing cache instance %s#%s data', $dir, $cacheInstanceName));
76+
$instances[$dirIndex][$cacheInstanceName]->clear();
77+
}
78+
}
79+
7080
$testHelper->terminateTest();

0 commit comments

Comments
 (0)