Skip to content

GridConfigService: request-scoped memoize getGridConfig - #488

Open
Ibochkarev wants to merge 3 commits into
betafrom
feat/issue-352-grid-config-memo
Open

GridConfigService: request-scoped memoize getGridConfig#488
Ibochkarev wants to merge 3 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 — по политике репозитория не обновлялся

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
@Ibochkarev Ibochkarev added priority: medium Средний приоритет enhancement New feature or request tech-debt Maintainability / refactor / architecture debt labels Jul 29, 2026
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.
@Ibochkarev
Ibochkarev force-pushed the feat/issue-352-grid-config-memo branch from 158603f to e0bbb73 Compare July 29, 2026 17:31
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

1 participant