| 1 | <?php |
||
| 8 | abstract class AbstractCache implements CacheInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Default time to live in seconds. |
||
| 12 | * |
||
| 13 | * @var integer |
||
| 14 | */ |
||
| 15 | private $defaultTimeToLive = CacheInterface::MAX_TTL; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Sets the default time to live in seconds. |
||
| 19 | * |
||
| 20 | * @param integer $defaultTimeToLive The time in seconds. |
||
| 21 | * |
||
| 22 | * @return void |
||
| 23 | */ |
||
| 24 | final public function setDefaultTTL(int $defaultTimeToLive) |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Returns the default time to live in seconds. |
||
| 31 | * |
||
| 32 | * @return integer The time in seconds. |
||
| 33 | */ |
||
| 34 | final public function getDefaultTTL() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Helper method to check TTL value. |
||
| 41 | * |
||
| 42 | * @param integer $ttl The time value to check in seconds. |
||
| 43 | * |
||
| 44 | * @return integer The valid $ttl value. |
||
| 45 | * |
||
| 46 | * @throws \InvalidArgumentException Thrown if $ttl is < 1 or > CacheInterface::MAX_TTL. |
||
| 47 | */ |
||
| 48 | final protected static function ensureTTL(int $ttl) |
||
| 56 | } |
||
| 57 |