Completed
Push — 1.x ( a98302...e42f79 )
by Alexander
07:32
created

CacheableDemo   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 21
rs 10
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2014, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Demo\Example;
12
13
use Demo\Annotation\Cacheable;
14
15
/**
16
 * Example class to show how to use caching with AOP
17
 */
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