From 77d04cb0aef90211949df0129758573378ff2b80 Mon Sep 17 00:00:00 2001 From: Jeremy Livingston Date: Wed, 14 Aug 2013 22:31:18 -0400 Subject: [PATCH] Add array key retrieval functionality --- Client/MemcacheClient.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Client/MemcacheClient.php b/Client/MemcacheClient.php index 33417b6..8849cf6 100644 --- a/Client/MemcacheClient.php +++ b/Client/MemcacheClient.php @@ -123,12 +123,30 @@ public function probeServer($ip, $port) */ public function get($key) { - if ($this->isSafe()) { - $key = $this->prefix . $key; + if (!$this->isSafe()) { + return false; + } + + if (empty($this->prefix)) { return $this->mem->get($key); } - return false; + if (!is_array($key)) { + return $this->mem->get($this->prefix . $key); + } + + foreach ($key as $index => $value) { + $key[$index] = $this->prefix . $value; + } + + $result = $this->mem->get($key); + + foreach ($result as $index => $value) { + $result[substr($index, strlen($this->prefix))] = $value; + unset($result[$index]); + } + + return $result; } /**