feat: add EID cache with per-source TTL#274
Open
MO-Thibault wants to merge 2 commits intoOptable:masterfrom
Open
feat: add EID cache with per-source TTL#274MO-Thibault wants to merge 2 commits intoOptable:masterfrom
MO-Thibault wants to merge 2 commits intoOptable:masterfrom
Conversation
Move extended EID caching logic from SDK wrapper bundles into the web-sdk. Wrappers currently copy-paste ~143 lines of merge/TTL code per customer — this centralizes it behind an `eidCache` config option. When `eidCache.enabled`, targeting() merges fresh EIDs with previously cached EIDs from localStorage, applying per-source TTL expiry (uidapi.com=1d, id5-sync.com=7d, default=3d). Configurable via the ttl map. Also exports mergeWithCache() for wrappers using resolveMultiNodeTargeting, and dispatches the optableResolved event for backward compatibility with existing Prebid RTD listeners. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3a9fb0f to
e61549d
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
eidCacheconfig option to the SDK constructor — when enabled,targeting()merges fresh EIDs with previously cached EIDs from localStorage, applying per-source TTL expirymergeWithCache()for wrappers usingresolveMultiNodeTargeting(longitudeads, unwind, mediavine, weatherchannel)optableResolvedevent onwindowanddocumentfor backward compat with existing Prebid RTD listenersWhy
8 SDK wrapper bundles in optable-solutions copy-paste ~143 lines of identical EID caching logic (
dedupeAndManageCache,saveResults,dispatchOptableResolved). 4 more customer repos (longitudeads, unwind, mediavine, weatherchannel) have similar implementations with minor variations. This centralizes the core logic so wrappers just seteidCache: { enabled: true }.Usage
For wrappers using
resolveMultiNodeTargeting:Default TTLs (baked in, overridable)
uidapi.comid5-sync.comTest plan
eid-cache.ts🤖 Generated with Claude Code