| 1 | <?php |
||
| 7 | class Ttl |
||
| 8 | { |
||
| 9 | const DEFAULT_GRACE_TTL = 60; |
||
| 10 | |||
| 11 | const DEFAULT_LOCK_TTL = 5; |
||
| 12 | |||
| 13 | /*** @var int */ |
||
| 14 | protected $ttl; |
||
| 15 | |||
| 16 | /*** @var int How long to serve stale content while new one is being generated */ |
||
| 17 | protected $graceTtl; |
||
| 18 | |||
| 19 | /*** @var int How long to prevent other requests to start generating same content */ |
||
| 20 | protected $lockTtl; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param int |
||
| 24 | * @param int Grace period |
||
| 25 | * @param int |
||
| 26 | */ |
||
| 27 | public function __construct($ttl, $graceTtl = null, $lockTtl = null) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return int |
||
| 42 | */ |
||
| 43 | public function getTtl() |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Get time how log it's really cached in cache store. |
||
| 50 | * |
||
| 51 | * @return int |
||
| 52 | */ |
||
| 53 | public function getRealTtl() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Gets grace period |
||
| 61 | * |
||
| 62 | * @return int |
||
| 63 | */ |
||
| 64 | public function getGraceTtl() |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @return int |
||
| 75 | */ |
||
| 76 | public function getLockTtl() |
||
| 84 | |||
| 85 | public function __toString() |
||
| 89 | } |
||
| 90 |