bear / query-repository
AboutResource Query Responsibility Segregation (RQRS) is a caching framework for BEAR.Sunday that optimizes performance by separating query and command responsibilities. It features event-driven cache invalidation, dependency resolution, donut caching, CDN integration, and conditional requests.
Requires
- php: ^8.2
- bear/resource: ^1.22.4
- bear/sunday: ^1.5
- koriym/semantic-logger: ^0.11
- psr/cache: ^1.0 || ^2.0 || ^3.0
- psr/log: ^2.0 || ^3.0
- ray/aop: ^2.19.1
- ray/di: ^2.20
- ray/psr-cache-module: ^1.6
- symfony/cache: ^6.0 || ^7.3 || ^8.0
- symfony/polyfill-php83: ^v1.32.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8
- bear/fastly-module: ^1.0
- madapaja/twig-module: ^2.6
- mobiledetect/mobiledetectlib: ^3.74 || ^4.8
- phpunit/phpunit: ^11.0
- predis/predis: ^2.4
- symfony/process: ^6.1 || ^7.1 || ^8.0
- twig/twig: ^3.4.3
Suggests
- ext-memcached: Required for Memcached cache storage backend
- ext-redis: Required for Redis cache storage backend
- bear/fastly-module: Required for FastlyModule (Fastly CDN purge)
- mobiledetect/mobiledetectlib: Required for MobileEtagModule (device-aware ETags)
Provides
None
Conflicts
None
Replaces
None
- 1.x-dev
- 1.18.0
- 1.17.x-dev
- 1.17.1
- 1.17.0
- 1.16.2
- 1.16.1
- 1.16.0
- 1.15.1
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.1
- 1.12.0
- 1.11.1
- 1.11.0
- 1.10.1
- 1.10.0
- 1.9.9
- 1.9.8
- 1.9.7
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.x-dev
- 1.8.6
- 1.8.5
- 1.8.4.x-dev
- 1.8.4-patch.1
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.13
- 1.6.12
- 1.6.11
- 1.6.10
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.5.0
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.0
- dev-claude/nice-allen-tp61ex
- dev-claude/skip-cleanup-for-unstorable
- dev-claude/coderabbit-auto-review
- dev-claude/require-psr-log-2
- dev-claude/psr-log-1-pool-error-logger
- dev-cache-observability-refactor
- dev-semantic-logger
- dev-improve-cache-observability
- dev-test-enhancement-cache-dependency
- dev-php82-readonly-optimization
- dev-phpcs
- dev-php84-win
- dev-spike
- dev-detached
- dev-refactor
This package is auto-updated.
Last update: 2026-10-29 19:56:20 UTC
README
The repository of the query side: a read model that writes keep current, not a cache left to expire.
A CQRS-style read side for BEAR.Sunday: the results of cacheable GETs are kept as read models. On a miss, onGet builds one on demand; the commands that change it refresh or purge it. A resource declares this with attributes and AOP does the rest - storing, answering conditional requests, and invalidating. By default an entry lives until a write invalidates it; a TTL is available for data that may simply go stale.
- The resource graph is the dependency graph: a cached child taken in with
#[Embed]becomes a dependency of the parent. - Writes invalidate: a command (
onPut,onPatch, ...) invalidates what it changes with#[Purge],#[Refresh]or#[RefreshCache], rather than waiting for expiry. - One tag crosses every layer: the origin cache, the ETag pool behind
304 Not Modified, and the CDN'sSurrogate-Keyare invalidated by the same tags. - Three uses of a child: a per-user hole (
#[DonutCache]), a hole rebuilt on events (#[CacheableResponse]), and material the page reads. - Verifiable: the semantic log records each store, hit, dependency and invalidation.
A cache attribute declares the response shared with every visitor: put per-user values in a non-cacheable #[DonutCache] hole.
Documentation
- Cache manual: English / 日本語
- Reading the Log (en / ja): every word the log can contain, and how to read a session
- Why the Log Records Everything (en / ja): the design rationale, the cost measurements, and why recording is off by default
- What the Log Proves (en / ja): the questions the log answers, and its declared boundaries
- LLM documentation
- Agent skills, via
/plugin install bear-skills: bear-cache-log and bear-cache-gate
