| 1 | <?php |
||
| 18 | class CacheableDemo |
||
| 19 | { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Returns a report and explicitly cache a result for future use |
||
| 23 | * |
||
| 24 | * In this example we use "Cacheable" annotation to explicit mark a method |
||
| 25 | * |
||
| 26 | * @param string $from This can be any value |
||
| 27 | * @Cacheable(time=10) |
||
| 28 | * |
||
| 29 | * @return string |
||
| 30 | */ |
||
| 31 | public function getReport($from) |
||
| 32 | { |
||
| 33 | // long calculation for 100ms |
||
| 34 | usleep(0.1 * 1e6); |
||
| 35 | |||
| 36 | return $from; |
||
| 37 | } |
||
| 38 | } |
||
| 39 |