@@ -54,7 +54,7 @@ public function getCachePool()
5454 */
5555 protected function doFetch ($ id )
5656 {
57- $ item = $ this ->cachePool ->getItem ($ id );
57+ $ item = $ this ->cachePool ->getItem ($ this -> normalizeKey ( $ id ) );
5858
5959 if ($ item ->isHit ()) {
6060 return $ item ->get ();
@@ -72,7 +72,7 @@ protected function doFetch($id)
7272 */
7373 protected function doContains ($ id )
7474 {
75- return $ this ->cachePool ->hasItem ($ id );
75+ return $ this ->cachePool ->hasItem ($ this -> normalizeKey ( $ id ) );
7676 }
7777
7878 /**
@@ -87,7 +87,7 @@ protected function doContains($id)
8787 */
8888 protected function doSave ($ id , $ data , $ lifeTime = 0 )
8989 {
90- $ item = $ this ->cachePool ->getItem ($ id );
90+ $ item = $ this ->cachePool ->getItem ($ this -> normalizeKey ( $ id ) );
9191 $ item ->set ($ data );
9292
9393 if ($ lifeTime !== 0 ) {
@@ -106,7 +106,7 @@ protected function doSave($id, $data, $lifeTime = 0)
106106 */
107107 protected function doDelete ($ id )
108108 {
109- return $ this ->cachePool ->deleteItem ($ id );
109+ return $ this ->cachePool ->deleteItem ($ this -> normalizeKey ( $ id ) );
110110 }
111111
112112 /**
@@ -130,4 +130,20 @@ protected function doGetStats()
130130 {
131131 // Not possible, as of yet
132132 }
133+
134+ /**
135+ * We need to make sure we do not use any characters not supported.
136+ *
137+ * @param string $key
138+ *
139+ * @return string
140+ */
141+ private function normalizeKey ($ key )
142+ {
143+ if (preg_match ('|[\{\}\(\)/ \\\@\:]| ' , $ key )) {
144+ return preg_replace ('|[\{\}\(\)/ \\\@\:]| ' , '_ ' , $ key );
145+ }
146+
147+ return $ key ;
148+ }
133149}
0 commit comments