Skip to content

GridConfigService: request-scoped memoize getGridConfig - #488

Merged
biz87 merged 4 commits into
betafrom
feat/issue-352-grid-config-memo
Aug 11, 2026
Merged

GridConfigService: request-scoped memoize getGridConfig#488
biz87 merged 4 commits into
betafrom
feat/issue-352-grid-config-memo

Conversation

@Ibochkarev

Copy link
Copy Markdown
Member

Описание

GridConfigService::getGridConfig() теперь кэширует результат в памяти инстанса сервиса (request-scoped через DI). Повторные вызовы с теми же (gridKey, includeHidden) не делают второй getCollection(msGridField).

Кэш сбрасывается в начале мутаций: saveGridConfig, addField, updateField, deleteField.

Тип изменений

  • Исправление бага
  • Новая функциональность (non-breaking change)
  • Breaking change
  • Рефакторинг / perf

Связанные Issues

Closes #352

Как это было протестировано?

cd core/components/minishop3
vendor/bin/phpunit tests/Unit/Services/GridConfigServiceMemoTest.php  # exit 0 (3 tests)
composer ci:php  # exit 0 (smoke 20 + phpunit 42 tests)
php -l src/Services/GridConfigService.php  # exit 0
  • Ручное тестирование
  • Автоматические тесты
  • Тестирование на разных версиях PHP/MODX

Конфигурация: PHP 8.4.17, branch feat/issue-352-grid-config-memo

Чеклист

  • Повторный getGridConfig с теми же аргументами — один hit в коллекцию
  • После saveGridConfig следующий read идёт в БД (invalidation)
  • Публичный shape ответа без изменений
  • CHANGELOG — по политике репозитория не обновлялся

@Ibochkarev Ibochkarev added priority: medium Средний приоритет enhancement New feature or request tech-debt Maintainability / refactor / architecture debt labels Jul 29, 2026
@Ibochkarev
Ibochkarev force-pushed the feat/issue-352-grid-config-memo branch 2 times, most recently from e0bbb73 to 0fcd1f9 Compare August 2, 2026 02:29
@Ibochkarev
Ibochkarev force-pushed the feat/issue-352-grid-config-memo branch 5 times, most recently from 616c59c to 9f40221 Compare August 10, 2026 02:00
Cache grid config by gridKey and includeHidden on the service instance,
and invalidate entries when grid config is mutated in the same request.

Closes #352
Expand the gridConfigCache docblock to state why the memo is safe only
under the DI singleton (one instance per request, no cross-request
persistence) and that all four mutation methods invalidate via
invalidateGridConfigCache().
Single entry point for cache invalidation before msGridField writes.
Drop typed $lexicon on GridConfigModxStub (conflicts with untyped modX stub)
and expect two getCollection calls after empty saveGridConfig, since
findNonSystemNotIn([]) short-circuits without a DB scan.
@Ibochkarev
Ibochkarev force-pushed the feat/issue-352-grid-config-memo branch from 9f40221 to 2e5259c Compare August 10, 2026 17:39
@biz87
biz87 merged commit 1a1bddc into beta Aug 11, 2026
3 checks passed
@Ibochkarev
Ibochkarev deleted the feat/issue-352-grid-config-memo branch August 11, 2026 18:13
@Ibochkarev
Ibochkarev requested a review from biz87 August 11, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: medium Средний приоритет tech-debt Maintainability / refactor / architecture debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] GridConfigService: request-scoped memoize getGridConfig

2 participants