Skip to content

Memoize the hydrated PublicSuffixList in-process - #93

Merged
sylfabre merged 1 commit into
mainfrom
feat/memoize-public-suffix-list-client
Aug 23, 2026
Merged

Memoize the hydrated PublicSuffixList in-process#93
sylfabre merged 1 commit into
mainfrom
feat/memoize-public-suffix-list-client

Conversation

@sylfabre

Copy link
Copy Markdown
Contributor

Summary

  • Adds MemoizingPublicSuffixListClient, an in-memory decorator around the PSR-16-cached RulesStorage, and points the Pdp\Storage\PublicSuffixListClient alias at it.
  • The PSR-16 cache already avoids re-downloading the Public Suffix List, but every get() call still reads the cache backend and unserializes the full Pdp\Rules object. Processes validating many email addresses (imports, campaigns) pay that cost on every validation. With this decorator the list is hydrated once per process and reused.
  • PublicSuffixListCacheWarmer keeps injecting RulesStorage directly, so cache warm-up behavior is unchanged.
  • Consuming applications that registered their own memoizing decorator for Pdp\Storage\PublicSuffixListClient can remove it after upgrading.

Test plan

  • New unit test asserts the decorated client is called once for repeated same-URI calls.
  • Full suite green (289 tests); phpcs, PHPStan and Rector all clean.

🤖 Generated with Claude Code

The PSR-16 cache avoids re-downloading the Public Suffix List, but every
PublicSuffixListClient::get() call still unserializes the full Rules
object from the cache backend. Processes validating many email addresses
pay that cost on every validation.

Pdp\Storage\PublicSuffixListClient is now aliased to an in-memory
memoizing decorator around RulesStorage, so the list is hydrated once
per process.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@sylfabre
sylfabre merged commit ceba33c into main Aug 23, 2026
5 checks passed
@sylfabre
sylfabre deleted the feat/memoize-public-suffix-list-client branch August 23, 2026 20:33
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.

1 participant