Skip to content

Refactor: Extract caching logic into dedicated cache classes in zmsdb #1799

@coderabbitai

Description

@coderabbitai

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions