Skip to content

Use datetime for absolute timestamps - #523

Merged
Dreamsorcerer merged 3 commits into
masterfrom
exptime
Nov 23, 2026
Merged

Dreamsorcerer merged 3 commits into
masterfrom
exptime

Conversation

@Dreamsorcerer

Copy link
Copy Markdown
Member

Support datetime for absolute timestamps and convert larger int values to continue working as relative values when above 30 days.

Fixes #517

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.17%. Comparing base (2ed53f2) to head (00aa414).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[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

Comment thread aiomcache/client.py Resolved
@Dreamsorcerer

Copy link
Copy Markdown
Member Author

@RayBB Please review.

@RayBB RayBB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 shown

Could we raise ValidationException there unless exptime >= int(time.time()), so only future timestamps take the deprecated path?

Optional:

  • stacklevel=4 will need to become 3 if #525 lands, since @acquire moves (the filename test will catch it).
  • append/prepend still accept True.
  • The _validate_exptime unit tests don't need the server fixture.

@Dreamsorcerer

Copy link
Copy Markdown
Member Author

I'm running low on time, could you just PR the suggestions into this branch?

@RayBB

RayBB commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@Dreamsorcerer No problem, opened #526 against this branch with the suggestions from my review. I left stacklevel as is for now, since it only needs to change if #525 lands.

@Dreamsorcerer
Dreamsorcerer merged commit 7f3eb46 into master Nov 23, 2026
14 checks passed
@Dreamsorcerer
Dreamsorcerer deleted the exptime branch November 23, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

set() with exptime over 30 days returns True but stores nothing

2 participants