Beispiel #1
0
 /**
  * Return the length of a given list or set.
  *
  * @param  string  $key
  * @param  string  $type
  * @return integer|\UnexpectedValueException
  */
 public function length($key, $type = null)
 {
     if (is_null($type)) {
         $type = $this->type($key);
     }
     switch ($type) {
         case 'list':
             return $this->database->llen($key);
         case 'zset':
             return $this->database->zcard($key);
         default:
             throw new UnexpectedValueException("List type '{$type}' not supported.");
     }
 }