File tree Expand file tree Collapse file tree 4 files changed +24
-13
lines changed Expand file tree Collapse file tree 4 files changed +24
-13
lines changed Original file line number Diff line number Diff line change 2020 */
2121class 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()
Original file line number Diff line number Diff line change 2222 */
2323interface 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 */
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments