iamsinghrajat/async-cache

Parameter time_to_live do it for hours, days, etc..

zuenko opened this issue · 2 comments

datetime.datetime.now() + self.time_to_live

self.time_to_live = datetime.timedelta(

It is better to pass the exact parameter for

@AsyncTTL(hours=1, seconds=1, days=0, milliseconds=0, ... etc. , maxsize=1024)

datetime.timedelta(
    days=days,
    seconds=seconds,
    microseconds=microseconds,
    milliseconds=milliseconds,
    minutes=minutes,
    hours=hours,
    weeks=weeks
)

@zuenko @inktrap We can easily pass time_to_live argument in seconds, datetime library will automatically convert it into microseconds or days accordingly. Passing hours,minutes, seconds or datetime object as argument separately make things complex.

>> datetime.timedelta(seconds=0.05)
datetime.timedelta(microseconds=50000)
>> datetime.timedelta(seconds=5000000)
datetime.timedelta(days=57, seconds=75200)