Skip to content

Commit d071e06

Browse files
committed
MemcachedStorage: the key must not include control characters or whitespace [Closes #13]
https://github.com/memcached/memcached/blob/master/doc/protocol.txt#L41
1 parent 4be4358 commit d071e06

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Caching/Storages/MemcachedStorage.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getConnection()
8383
*/
8484
public function read($key)
8585
{
86-
$key = $this->prefix . $key;
86+
$key = urlencode($this->prefix . $key);
8787
$meta = $this->memcache->get($key);
8888
if (!$meta) {
8989
return NULL;
@@ -133,7 +133,7 @@ public function write($key, $data, array $dp)
133133
throw new Nette\NotSupportedException('Dependent items are not supported by MemcachedStorage.');
134134
}
135135

136-
$key = $this->prefix . $key;
136+
$key = urlencode($this->prefix . $key);
137137
$meta = array(
138138
self::META_DATA => $data,
139139
);
@@ -168,7 +168,7 @@ public function write($key, $data, array $dp)
168168
*/
169169
public function remove($key)
170170
{
171-
$this->memcache->delete($this->prefix . $key, 0);
171+
$this->memcache->delete(urlencode($this->prefix . $key), 0);
172172
}
173173

174174

0 commit comments

Comments
 (0)