Webmozart\KeyValueStore\Api\KeyValueStore::getMultiple PHP Method

getMultiple() public method

The passed default value is returned for keys that don't exist. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be read, a {@link ReadException} is thrown. You should always handle this exception in your code: php try { $value = $store->getMultiple(array($key1, $key2)); } catch (ReadException $e) { read failed }
public getMultiple ( array $keys, mixed $default = null ) : array
$keys array The keys to get. The keys must be strings or integers.
$default mixed The default value to return for keys that are not found.
return array The values of the passed keys, indexed by the keys.
    public function getMultiple(array $keys, $default = null);

Usage Example

 private function loadAllBindings()
 {
     $keysToFetch = array();
     foreach ($this->keysByTypeName as $key) {
         if (!isset($this->bindingsByKey[$key])) {
             $keysToFetch[] = 'b:' . $key;
         }
     }
     $fetchedBindings = $this->store->getMultiple($keysToFetch);
     foreach ($fetchedBindings as $key => $bindingsForKey) {
         $this->bindingsByKey[$key] = $bindingsForKey ?: array();
         $this->initializeBindings($this->bindingsByKey[$key]);
     }
 }
All Usage Examples Of Webmozart\KeyValueStore\Api\KeyValueStore::getMultiple