Skip to content

Make weekly Redis key strategy configurable #265

@ryz310

Description

@ryz310

Background

This gem generates Redis keys (e.g. weekly_*) based on UNIX time.

Currently, weekly keys are generated using:

strftime('%YW%W')

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions