Background
Currently, caching logic is embedded directly within domain classes like Useraccount and Scope in zmsdb. This makes these classes more complex and mixes caching concerns with business logic.
Proposed Solution
Extract all caching-related methods into dedicated cache classes under a new directory structure:
zmsdb/src/Zmsdb/Cache/
├── Useraccount.php
├── Scope.php
└── [other cache classes as needed]
Scope
For the Useraccount class, methods to extract include:
getUseraccountCacheVersion()
sanitizeCacheKey()
registerCacheKeyForDepartments()
deleteCacheKey()
invalidateDepartmentCaches()
getCacheIndexKey()
collectDepartmentIdsForInvalidation()
collectUseraccountIdentifiers()
removeCache()
- Cache key building helpers (
buildSearchCacheKey, getCachedResult, setCachedResult)
Similar refactoring should be done for Scope and any other classes with embedded caching logic.
Benefits
- Better separation of concerns
- Reduced class complexity
- Easier to test caching logic independently
- Improved maintainability
- Aligns with Single Responsibility Principle
Implementation Notes
The extracted cache classes should:
- Handle all cache key generation and sanitization
- Manage cache versioning and invalidation
- Provide clear interfaces for the domain classes to use
- Maintain backward compatibility during the transition
Related
Background
Currently, caching logic is embedded directly within domain classes like
UseraccountandScopein zmsdb. This makes these classes more complex and mixes caching concerns with business logic.Proposed Solution
Extract all caching-related methods into dedicated cache classes under a new directory structure:
Scope
For the
Useraccountclass, methods to extract include:getUseraccountCacheVersion()sanitizeCacheKey()registerCacheKeyForDepartments()deleteCacheKey()invalidateDepartmentCaches()getCacheIndexKey()collectDepartmentIdsForInvalidation()collectUseraccountIdentifiers()removeCache()buildSearchCacheKey,getCachedResult,setCachedResult)Similar refactoring should be done for
Scopeand any other classes with embedded caching logic.Benefits
Implementation Notes
The extracted cache classes should:
Related