Skip to content

[cache-core] Reject invalid capacity and cleanup intervals before creating timers #1707

Description

@kang-heewon

Priority: P1

Problem

InMemoryCacheStore validates TTL but forwards maxEntries and cleanupIntervalMs directly to overflow eviction and setInterval. NaN capacity disables eviction and non-positive or invalid intervals can create a hot timer.

Evidence

packages/cache-core/src/libs/InMemoryCacheStore.ts validates TTL while maxEntries flows to evictOverflow() and cleanupIntervalMs to setInterval() without equivalent validation.

Desired outcome

Cache resource bounds are valid before memory or timer resources are allocated.

Implementation path

  1. Add shared cache numeric validation and an InvalidCacheConfigurationProblem.
  2. Require positive safe-integer capacity and positive bounded timer delay.
  3. Cover zero, negatives, NaN, Infinity, fractions, and valid boundaries.

Acceptance criteria

  • Invalid capacity or cleanup interval fails fast.
  • A valid store retains current cleanup behavior.
  • No invalid option can disable eviction or create a hot timer.

Validation

pnpm --filter @croco/cache-core test

Scope boundaries

Does not add a distributed cache adapter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1 issuecache-coreruntimeRuntime behavior, lifecycle, and environment capability work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions