Skip to content

Commit

Permalink
Merge pull request #412 from Geolim4/final
Browse files Browse the repository at this point in the history
- Removed unused method encodeFilename() on DriverBaseTrait
- Fixed #411
  • Loading branch information
Geolim4 committed Jan 4, 2017
2 parents 62e788a + 1fdda2c commit 78a4d6a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
6 changes: 5 additions & 1 deletion src/phpFastCache/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class Api
{
protected static $version = '1.1.2';
protected static $version = '1.1.3';

/**
* This method will returns the current
Expand All @@ -45,6 +45,10 @@ public static function getVersion()
public static function getChangelog()
{
return <<<CHANGELOG
- 1.1.3
-- Added an additional CacheItemInterface method:
ExtendedCacheItemInterface::getEncodedKey()
- 1.1.2
-- Implemented [de|a]ttaching methods to improve memory management
ExtendedCacheItemPoolInterface::detachItem()
Expand Down
9 changes: 0 additions & 9 deletions src/phpFastCache/Cache/DriverBaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ trait DriverBaseTrait
*/
protected $instance;

/**
* @param $keyword
* @return string
*/
protected function encodeFilename($keyword)
{
return md5($keyword);
}

/**
* @param $config_name
* @param string $value
Expand Down
9 changes: 9 additions & 0 deletions src/phpFastCache/Cache/ExtendedCacheItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
*/
interface ExtendedCacheItemInterface extends CacheItemInterface, \JsonSerializable
{
/**
* Returns the encoded key for the current cache item.
* Usually as a MD5 hash
*
* @return string
* The encoded key string for this cache item.
*/
public function getEncodedKey();

/**
* @return mixed
*/
Expand Down
7 changes: 7 additions & 0 deletions src/phpFastCache/Cache/ItemBaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ public function expiresAfter($time)
*
*******************/

/**
* @return string
*/
public function getEncodedKey()
{
return md5($this->getKey());
}

/**
* @return mixed
Expand Down
15 changes: 3 additions & 12 deletions src/phpFastCache/Drivers/Ssdb/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,7 @@ protected function driverWrite(CacheItemInterface $item)
* Check for Cross-Driver type confusion
*/
if ($item instanceof Item) {
/* if (isset($this->config[ 'skipExisting' ]) && $this->config[ 'skipExisting' ] == true) {
$x = $this->instance->get($item->getKey());
if ($x === false) {
return false;
} elseif (!is_null($x)) {
return true;
}
}*/

return $this->instance->setx($item->getKey(), $this->encode($this->driverPreWrap($item)), $item->getTtl());
return $this->instance->setx($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), $item->getTtl());
} else {
throw new \InvalidArgumentException('Cross-Driver type confusion detected');
}
Expand All @@ -96,7 +87,7 @@ protected function driverWrite(CacheItemInterface $item)
*/
protected function driverRead(CacheItemInterface $item)
{
$val = $this->instance->get($item->getKey());
$val = $this->instance->get($item->getEncodedKey());
if ($val == false) {
return null;
} else {
Expand All @@ -115,7 +106,7 @@ protected function driverDelete(CacheItemInterface $item)
* Check for Cross-Driver type confusion
*/
if ($item instanceof Item) {
return $this->instance->del($item->get());
return $this->instance->del($item->getEncodedKey());
} else {
throw new \InvalidArgumentException('Cross-Driver type confusion detected');
}
Expand Down

0 comments on commit 78a4d6a

Please sign in to comment.