chance src/Cache.py from time.monotonic() to time.time()
This commit is contained in:
parent
48cc92cea3
commit
bc6b1dda47
1 changed files with 4 additions and 4 deletions
|
@ -14,7 +14,7 @@ class Cache(PollHook.PollHook):
|
||||||
return self._cache(key, value, None)
|
return self._cache(key, value, None)
|
||||||
def temporary_cache(self, key: str, value: typing.Any, timeout: float
|
def temporary_cache(self, key: str, value: typing.Any, timeout: float
|
||||||
)-> str:
|
)-> str:
|
||||||
return self._cache(key, value, time.monotonic()+timeout)
|
return self._cache(key, value, time.time()+timeout)
|
||||||
def _cache(self, key: str, value: typing.Any,
|
def _cache(self, key: str, value: typing.Any,
|
||||||
expiration: typing.Optional[float]) -> str:
|
expiration: typing.Optional[float]) -> str:
|
||||||
id = self.cache_key(key)
|
id = self.cache_key(key)
|
||||||
|
@ -30,7 +30,7 @@ class Cache(PollHook.PollHook):
|
||||||
expirations = list(filter(None, expirations))
|
expirations = list(filter(None, expirations))
|
||||||
if not expirations:
|
if not expirations:
|
||||||
return None
|
return None
|
||||||
now = time.monotonic()
|
now = time.time()
|
||||||
expirations = [e-now for e in expirations]
|
expirations = [e-now for e in expirations]
|
||||||
|
|
||||||
expiration = max(min(expirations), 0)
|
expiration = max(min(expirations), 0)
|
||||||
|
@ -38,7 +38,7 @@ class Cache(PollHook.PollHook):
|
||||||
return expiration
|
return expiration
|
||||||
|
|
||||||
def call(self):
|
def call(self):
|
||||||
now = time.monotonic()
|
now = time.time()
|
||||||
expired = []
|
expired = []
|
||||||
for id in self._items.keys():
|
for id in self._items.keys():
|
||||||
key, value, expiration = self._items[id]
|
key, value, expiration = self._items[id]
|
||||||
|
@ -63,4 +63,4 @@ class Cache(PollHook.PollHook):
|
||||||
return expiration
|
return expiration
|
||||||
def until_expiration(self, key: typing.Any) -> float:
|
def until_expiration(self, key: typing.Any) -> float:
|
||||||
expiration = self.get_expiration(key)
|
expiration = self.get_expiration(key)
|
||||||
return expiration-time.monotonic()
|
return expiration-time.time()
|
||||||
|
|
Loading…
Reference in a new issue