RetrievesMultipleKeys.php 799B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Illuminate\Cache;
  3. trait RetrievesMultipleKeys
  4. {
  5. /**
  6. * Retrieve multiple items from the cache by key.
  7. *
  8. * Items not found in the cache will have a null value.
  9. *
  10. * @param array $keys
  11. * @return array
  12. */
  13. public function many(array $keys)
  14. {
  15. $return = [];
  16. foreach ($keys as $key) {
  17. $return[$key] = $this->get($key);
  18. }
  19. return $return;
  20. }
  21. /**
  22. * Store multiple items in the cache for a given number of minutes.
  23. *
  24. * @param array $values
  25. * @param float|int $minutes
  26. * @return void
  27. */
  28. public function putMany(array $values, $minutes)
  29. {
  30. foreach ($values as $key => $value) {
  31. $this->put($key, $value, $minutes);
  32. }
  33. }
  34. }