Skip to content

CacheLayer 3.3: expand atomic cache backend coverage - #28

Merged
abmmhasan merged 19 commits into
mainfrom
feature/atomic-backend-expansion
Sep 7, 2026
Merged

CacheLayer 3.3: expand atomic cache backend coverage#28
abmmhasan merged 19 commits into
mainfrom
feature/atomic-backend-expansion

Conversation

@abmmhasan

Copy link
Copy Markdown
Member

Summary

Expand the optional Cache::atomic() capability to additional backends while preserving the existing full three-operation contract (setIfAbsent, strict compareAndSet, getAndDelete).

Batch 1 — WeakMap

  • Add process-local atomic capability.
  • Preserve strict PHP comparison semantics and collected-reference behavior.

Batch 2 — Memcached

  • Add native CAS-backed conditional replacement.
  • Add add()-based atomic claim.
  • Add CAS tombstone consume semantics so getAndDelete() cannot delete a concurrent replacement.
  • Preserve namespace and tag-generation validity.

Batch 3 — File / PHP files

  • Add deterministic per-key flock() coordination.
  • Make ordinary save() / deleteItem() mutations share the same key lock as atomic operations.
  • Keep reads lock-free over atomic rename replacement.

Batch 4 — PDO

  • Add driver-qualified atomic capability for SQLite, PostgreSQL, MySQL, and MariaDB.
  • SQLite uses BEGIN IMMEDIATE.
  • PostgreSQL/MySQL/MariaDB use transactions with row locking and conflict-safe inserts.
  • Other PDO drivers continue to return no atomic capability.
  • Reject atomic operations inside caller-owned active PDO transactions.

Tests / docs

  • Add backend-expansion contract tests.
  • Update SQLite capability expectations.
  • Document the expanded backend matrix and consistency domains.

APCu, ScyllaDB, Null, and Tiered remain intentionally unsupported.

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PHPStan found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@abmmhasan
abmmhasan merged commit b064b81 into main Sep 7, 2026
12 checks passed
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.

2 participants