Repository navigation
Use datetime for absolute timestamps - #523
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #523 +/- ##
==========================================
+ Coverage 96.84% 97.17% +0.33%
==========================================
Files 10 10
Lines 887 992 +105
Branches 46 54 +8
==========================================
+ Hits 859 964 +105
Misses 17 17
Partials 11 11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
[Medium impact] The PR appears safe to merge; no new blocking issues were found. Reviews (3) · Last reviewed commit: "Reject int exptime that is a past Unix t..." · Reviewed by Greptile |
|
@RayBB Please review. |
RayBB
left a comment
There was a problem hiding this comment.
Thanks, this looks good and fixes #517 for me. I checked the stored TTL with mg key t against memcached 1.6.45 for set/add/replace/cas/touch at 30d, 30d+1, 1y and 10y, and with aware, naive and past datetimes. All behave as expected.
One case still loses data silently: an int TTL between about 11 years and "now" (~1.8e9) is read as a past timestamp, and when the call comes from library code, the DeprecationWarning is hidden by default:
# in mycache.py
await mc.set(b"y", b"1", 20 * 365 * 86400) # -> True
await mc.get(b"y") # -> None, no warning shownCould we raise ValidationException there unless exptime >= int(time.time()), so only future timestamps take the deprecated path?
Optional:
stacklevel=4will need to become 3 if #525 lands, since@acquiremoves (the filename test will catch it).- append/prepend still accept
True. - The
_validate_exptimeunit tests don't need the server fixture.
|
I'm running low on time, could you just PR the suggestions into this branch? |
|
@Dreamsorcerer No problem, opened #526 against this branch with the suggestions from my review. I left |
Support datetime for absolute timestamps and convert larger int values to continue working as relative values when above 30 days.
Fixes #517