Skip to content

Conversation

@CodeWithKyrian
Copy link
Contributor

Problem

The Registry::load() method contained a critical bug where it called clear() which:

  1. Deleted the cache from storage
  2. Cleared local variables
  3. Then tried to read from the now-empty cache

This meant the cache was always empty when loading, making the entire caching system ineffective and causing performance issues for applications with many discovered elements, and discoverability isses for all servers using discovered elements.

Solution

Modified the Registry::clear() method to accept an optional $includeCache parameter:

  • clear() - Default behavior unchanged (clears cache + local elements)
  • clear(false) - New option to clear only local elements, preserving cache
  • load() - Now calls clear(false) to preserve cache during loading

Backward Compatibility

No breaking changes - existing clear() calls work identically
Default parameter maintains existing API behavior
Safe for patch release - 3.0.2

The Registry::load() method was incorrectly calling clear() which deleted
the cache before attempting to read from it, making caching completely
ineffective. Modified clear() to accept an optional $includeCache parameter
(default: true) to maintain backward compatibility while allowing load() to
clear only local elements without destroying the cache.
@CodeWithKyrian CodeWithKyrian merged commit 9e4806e into main Jun 25, 2025
8 checks passed
@CodeWithKyrian CodeWithKyrian deleted the fix/registry-cache-clearing-bug branch June 25, 2025 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants