Skip to content

Commit 78a4d6a

Browse files
authored
Merge pull request #412 from Geolim4/final
- Removed unused method encodeFilename() on DriverBaseTrait - Fixed #411
2 parents 62e788a + 1fdda2c commit 78a4d6a

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

src/phpFastCache/Api.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class Api
2222
{
23-
protected static $version = '1.1.2';
23+
protected static $version = '1.1.3';
2424

2525
/**
2626
* This method will returns the current
@@ -45,6 +45,10 @@ public static function getVersion()
4545
public static function getChangelog()
4646
{
4747
return <<<CHANGELOG
48+
- 1.1.3
49+
-- Added an additional CacheItemInterface method:
50+
ExtendedCacheItemInterface::getEncodedKey()
51+
4852
- 1.1.2
4953
-- Implemented [de|a]ttaching methods to improve memory management
5054
ExtendedCacheItemPoolInterface::detachItem()

src/phpFastCache/Cache/DriverBaseTrait.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ trait DriverBaseTrait
3939
*/
4040
protected $instance;
4141

42-
/**
43-
* @param $keyword
44-
* @return string
45-
*/
46-
protected function encodeFilename($keyword)
47-
{
48-
return md5($keyword);
49-
}
50-
5142
/**
5243
* @param $config_name
5344
* @param string $value

src/phpFastCache/Cache/ExtendedCacheItemInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
*/
2323
interface ExtendedCacheItemInterface extends CacheItemInterface, \JsonSerializable
2424
{
25+
/**
26+
* Returns the encoded key for the current cache item.
27+
* Usually as a MD5 hash
28+
*
29+
* @return string
30+
* The encoded key string for this cache item.
31+
*/
32+
public function getEncodedKey();
33+
2534
/**
2635
* @return mixed
2736
*/

src/phpFastCache/Cache/ItemBaseTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ public function expiresAfter($time)
190190
*
191191
*******************/
192192

193+
/**
194+
* @return string
195+
*/
196+
public function getEncodedKey()
197+
{
198+
return md5($this->getKey());
199+
}
193200

194201
/**
195202
* @return mixed

src/phpFastCache/Drivers/Ssdb/Driver.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,7 @@ protected function driverWrite(CacheItemInterface $item)
7575
* Check for Cross-Driver type confusion
7676
*/
7777
if ($item instanceof Item) {
78-
/* if (isset($this->config[ 'skipExisting' ]) && $this->config[ 'skipExisting' ] == true) {
79-
$x = $this->instance->get($item->getKey());
80-
if ($x === false) {
81-
return false;
82-
} elseif (!is_null($x)) {
83-
return true;
84-
}
85-
}*/
86-
87-
return $this->instance->setx($item->getKey(), $this->encode($this->driverPreWrap($item)), $item->getTtl());
78+
return $this->instance->setx($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), $item->getTtl());
8879
} else {
8980
throw new \InvalidArgumentException('Cross-Driver type confusion detected');
9081
}
@@ -96,7 +87,7 @@ protected function driverWrite(CacheItemInterface $item)
9687
*/
9788
protected function driverRead(CacheItemInterface $item)
9889
{
99-
$val = $this->instance->get($item->getKey());
90+
$val = $this->instance->get($item->getEncodedKey());
10091
if ($val == false) {
10192
return null;
10293
} else {
@@ -115,7 +106,7 @@ protected function driverDelete(CacheItemInterface $item)
115106
* Check for Cross-Driver type confusion
116107
*/
117108
if ($item instanceof Item) {
118-
return $this->instance->del($item->get());
109+
return $this->instance->del($item->getEncodedKey());
119110
} else {
120111
throw new \InvalidArgumentException('Cross-Driver type confusion detected');
121112
}

0 commit comments

Comments
 (0)