memoize() public static méthode

Example: $countries = Cache::memoize(function() {{ expensive computation that returns a list of countries return Country:all(); })
public static memoize ( $function ) : mixed | null
$function
Résultat mixed | null
Exemple #1
0
 /**
  * @test
  */
 public function shouldUseDifferentKeysForDifferentClosures()
 {
     //when
     $result1 = Cache::memoize(function () {
         return 1;
     });
     $result2 = Cache::memoize(function () {
         return 2;
     });
     //then
     $this->assertEquals(2, Cache::size());
     $this->assertEquals(1, $result1);
     $this->assertEquals(2, $result2);
 }