1 | <?php |
||
10 | class IpListJsonCache implements IpListCacheInterface |
||
11 | { |
||
12 | const DEFAULT_LOCATION = '/tmp/tor-exits.cache.json'; |
||
13 | const DEFAULT_TTL = 7200; |
||
14 | |||
15 | protected $location; |
||
16 | protected $ttl; |
||
17 | |||
18 | /** |
||
19 | * Setter for location |
||
20 | * |
||
21 | * @param string $location |
||
22 | * @return IpListJsonCache |
||
23 | */ |
||
24 | 6 | public function setLocation($location) |
|
30 | |||
31 | /** |
||
32 | * Setter for ttl |
||
33 | * |
||
34 | * @param int $ttl |
||
35 | * @return IpListJsonCache |
||
36 | */ |
||
37 | 2 | public function setTtl($ttl) |
|
46 | |||
47 | /** |
||
48 | * Getter for location |
||
49 | * |
||
50 | * return string |
||
51 | */ |
||
52 | 7 | public function getLocation() |
|
56 | |||
57 | /** |
||
58 | * Getter for location |
||
59 | * |
||
60 | * return int |
||
61 | */ |
||
62 | 3 | public function getTtl() |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 3 | public function store(IpList $ipList, $ttl = null) |
|
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | 4 | public function fetch() |
|
104 | |||
105 | /** |
||
106 | * calculateExpiration, calculate expiration DateTime based on ttl |
||
107 | * |
||
108 | * @param int|null $ttl |
||
109 | * @return DateTime |
||
110 | */ |
||
111 | 3 | protected function calculateExpiration($ttl = null) |
|
118 | } |
||
119 |