File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,14 @@ cdef class DNSRecord(DNSEntry):
46
46
47
47
cpdef set_created_ttl(self , cython.float created, cython.float ttl)
48
48
49
+ cpdef get_remaining_ttl(self , cython.float current_time)
50
+
51
+ cpdef is_expired(self , cython.float current_time)
52
+
53
+ cpdef is_stale(self , cython.float current_time)
54
+
55
+ cpdef is_recent(self , cython.float current_time)
56
+
49
57
cdef class DNSAddress(DNSRecord):
50
58
51
59
cdef public cython.int _hash
Original file line number Diff line number Diff line change @@ -192,19 +192,19 @@ def get_expiration_time(self, percent: int_) -> float:
192
192
return self .created + (percent * self .ttl * 10 )
193
193
194
194
# TODO: Switch to just int here
195
- def get_remaining_ttl (self , now : float ) -> int_or_float_ :
195
+ def get_remaining_ttl (self , now : float_ ) -> int_or_float_ :
196
196
"""Returns the remaining TTL in seconds."""
197
197
return max (0 , millis_to_seconds ((self .created + (_EXPIRE_FULL_TIME_MS * self .ttl )) - now ))
198
198
199
- def is_expired (self , now : float ) -> bool :
199
+ def is_expired (self , now : float_ ) -> bool :
200
200
"""Returns true if this record has expired."""
201
201
return self .creat
8765
ed + (_EXPIRE_FULL_TIME_MS * self .ttl ) <= now
202
202
203
- def is_stale (self , now : float ) -> bool :
203
+ def is_stale (self , now : float_ ) -> bool :
204
204
"""Returns true if this record is at least half way expired."""
205
205
return self .created + (_EXPIRE_STALE_TIME_MS * self .ttl ) <= now
206
206
207
- def is_recent (self , now : float ) -> bool :
207
+ def is_recent (self , now : float_ ) -> bool :
208
208
"""Returns true if the record more than one quarter of its TTL remaining."""
209
209
return self .created + (_RECENT_TIME_MS * self .ttl ) > now
210
210
You can’t perform that action at this time.
0 commit comments