Background
This gem generates Redis keys (e.g. weekly_*) based on UNIX time.
Currently, weekly keys are generated using:
This causes an issue when a week spans across a year boundary.
For example, the same logical week results in different keys:
- 2025-12-31 →
2025W52
- 2026-01-01 →
2026W00
PR #264 fixes this by generating weekly keys based on the Monday of the week, so the key remains stable across year boundaries.
Problem
While the fix is more intuitive, it changes existing Redis key names, which is a breaking change for current users.
Proposal
Introduce a configuration option to let users choose the weekly key strategy:
Redis::Objects::Periodical.configure do |config|
# :legacy -> current behavior (strftime('%YW%W'))
# :monday -> week-start (Monday) based strategy (PR #264)
config.weekly_key_strategy = :legacy
end
- Default:
:legacy (backward compatible)
- Future major version may switch default to
:monday
Feedback welcome
- Config naming / API design
- Default behavior preference
- Migration concerns
Any feedback is appreciated.