Example #1
0
 /**
  * Get multiple values from the cache.
  *
  * @param array $keys An array of keys to get
  *
  * @return array An array of JSON objects
  */
 public function mget(array $keys = array())
 {
     $values = $this->client->mget($keys);
     $rtn = [];
     // The Redis extension returns false not null for nonexistent
     // values. For consistency's sake, we spoof that here
     foreach ($keys as $index => $key) {
         $value = $values[$index];
         $rtn[$this->instance->unkey($key)] = $value;
     }
     return $rtn;
 }
Example #2
0
 /**
  * Get multiple values from the cache.
  *
  * @param array $keys An array of keys to get
  *
  * @return array An array of JSON objects
  */
 public function mget(array $keys = array())
 {
     $values = $this->client->getMulti($keys);
     $rtn = [];
     // The Memcached extension returns false not null for nonexistent
     // values. For consistency's sake, we spoof that here
     foreach ($keys as $key) {
         if (!isset($values[$key]) || $values[$key] === false) {
             $values[$key] = null;
         }
         $rtn[$this->instance->unkey($key)] = $values[$key];
     }
     return $rtn;
 }
Example #3
0
 /**
  * Tests that the instance key is removed from keys.
  *
  * @covers Molovo\Amnesia\Cache\Instance::unkey
  */
 public function testUnkey()
 {
     $str = '0b4e02e6.a.test.key';
     $key = static::$instance->unkey($str);
     $expected = 'a.test.key';
     verify($key)->equals($expected);
 }
Example #4
0
 /**
  * Get multiple values from the cache.
  *
  * @param array $keys An array of keys to get
  *
  * @return array An array of JSON objects
  */
 public function mget(array $keys = array())
 {
     $values = [];
     foreach ($keys as $key) {
         $values[$this->instance->unkey($key)] = $this->get($key);
     }
     return $values;
 }