Skip to content

Introduce shared Store drivers and refactor Session/Cache/Throttle to use them#2

Draft
ismailian wants to merge 1 commit intomainfrom
codex/refactor-drivers-for-session,-cache,-throttle
Draft

Introduce shared Store drivers and refactor Session/Cache/Throttle to use them#2
ismailian wants to merge 1 commit intomainfrom
codex/refactor-drivers-for-session,-cache,-throttle

Conversation

@ismailian
Copy link
Copy Markdown
Owner

Motivation

  • Reduce duplication by extracting generic storage primitives that can be reused by Session, Cache and Throttle layers.
  • Keep backend implementations (filesystem, Redis, database) centralized and driver-agnostic so each core (Session/Cache/Throttle) only contains behaviour specific to its responsibilities.
  • Allow adding new backends (e.g. DB-backed cache) without duplicating storage logic across subsystems.

Description

  • Added a new shared driver layer under System/Drivers with a generic StoreDriver contract and implementations: FilesystemDriver, RedisDriver, and DatabaseDriver which expose getAll, get, set, delete, increment, and ttl APIs.
  • Refactored Session drivers (System/Session/Drivers/{FileDriver,RedisDriver,DbDriver}) to delegate storage to the shared store drivers while preserving session-facing methods (read, write, delete, getAll).
  • Refactored Cache drivers to use the shared drivers and added System/Cache/Drivers/DbDriver, and updated System/Cache/Cache.php to support DataSource::DATABASE in the init() driver selection.
  • Refactored Throttle drivers to delegate counters/TTL semantics to the shared drivers and implemented the RateLimiterDriver adapters (FilesystemDriver, RedisDriver, DatabaseDriver) to expose get, increment, ttl, and reset while keeping rate-limit logic in RateLimiter.

Testing

  • Ran PHP lint across the new/modified files using php -l for System/Drivers/*, System/Session/Drivers/*, System/Cache/*, and System/Throttle/Drivers/*, and all files reported No syntax errors detected.
  • No automated unit tests were present; validation was limited to the syntax/lint checks which succeeded.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant