1 | <?php |
||
42 | class CachedCallable extends ExtensionAbstract |
||
43 | { |
||
44 | /** |
||
45 | * default ttl for the cached callable result |
||
46 | * |
||
47 | * @var int |
||
48 | * @access protected |
||
49 | */ |
||
50 | protected $ttl = 86400; |
||
51 | |||
52 | /** |
||
53 | * {@inheritDoc} |
||
54 | */ |
||
55 | public function methodsAvailable()/*# : array */ |
||
59 | |||
60 | /** |
||
61 | * Complete cycle of get cached result of a callable |
||
62 | * |
||
63 | * 1. if first argument is int, it is a TTL |
||
64 | * 2. otherwise the first argument is a callable |
||
65 | * 3. the remaining are the arguments for the callable |
||
66 | * |
||
67 | * @return mixed |
||
68 | * @throws \Exception except from callable execution |
||
69 | * @access public |
||
70 | * @api |
||
71 | */ |
||
72 | public function callableCache() |
||
95 | |||
96 | /** |
||
97 | * The real boot method |
||
98 | * |
||
99 | * @access protected |
||
100 | */ |
||
101 | protected function bootExtension() |
||
104 | |||
105 | /** |
||
106 | * Get TTL and unique key |
||
107 | * |
||
108 | * @param array &$args |
||
109 | * @return array |
||
110 | * @access protected |
||
111 | */ |
||
112 | protected function getTtlAndKey(array &$args)/*# : array */ |
||
123 | |||
124 | /** |
||
125 | * Generate key base on input |
||
126 | * |
||
127 | * @param mixed $reference reference data |
||
128 | * @return string |
||
129 | * @access protected |
||
130 | */ |
||
131 | protected function generateKey($reference)/*# : string */ |
||
139 | |||
140 | /** |
||
141 | * flat the reference array to make it easy for serialize |
||
142 | * |
||
143 | * @param array $reference reference data |
||
144 | * @return array flattered array |
||
145 | * @access protected |
||
146 | */ |
||
147 | protected function flatReference(array $reference)/*# : array */ |
||
160 | } |
||
161 |