Skip to content

[Billing Plans]: Update product caching cache key#6801

Merged
fire-at-will merged 3 commits into
billing-plans-devfrom
product-cache-key
May 19, 2026
Merged

[Billing Plans]: Update product caching cache key#6801
fire-at-will merged 3 commits into
billing-plans-devfrom
product-cache-key

Conversation

@fire-at-will

@fire-at-will fire-at-will commented May 14, 2026

Copy link
Copy Markdown
Contributor

Description

Modifies the SDK's product cache to use StoreProduct.id instead of the productIdentifier. This allows us to avoid cache key conflicts for products with billing plans since the cache will now store separate values for com.rc.product and com.rc.product:monthly.


Note

Medium Risk
Changes the cache key used for StoreKit product lookups, which can alter cache hit/miss behavior and increase product fetches if any callers still request by productIdentifier instead of StoreProduct.id. Covered by new unit tests around base vs billing-plan IDs, but impacts purchasing performance/behavior paths.

Overview
Product caching now keys entries by StoreProduct.id instead of productIdentifier, so billing-plan variants like com.rc.product:monthly no longer overwrite or satisfy requests for the base com.rc.product (and vice versa).

Adds focused unit tests to verify correct cache behavior for base vs installment/billing-plan products: cached hits by id, no cross-serving between base and monthly IDs, and mixed requests only fetch missing IDs.

Reviewed by Cursor Bugbot for commit 3ac1f6c. Bugbot is set up for automated code reviews on this repo. Configure here.

@fire-at-will fire-at-will requested a review from a team as a code owner May 14, 2026 19:35
@fire-at-will fire-at-will changed the title update product caching cache key [Billing Plans]: Update product caching cache key May 14, 2026

expect(result.onlyElement) === product
self.expectProductsWereFetched(times: 1, for: product.id)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly, should we add an extra test for the same productIdentifier but different id so that cachingManager.products returns the same product 2 times (1 per installment info)?

Like the example stated in the PR description: com.rc.product and com.rc.product:monthly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! :D

Added that test + several others in 7403322

@fire-at-will fire-at-will requested a review from ajpallares May 15, 2026 18:55

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@fire-at-will fire-at-will merged commit 0cf2421 into billing-plans-dev May 19, 2026
42 of 43 checks passed
@fire-at-will fire-at-will deleted the product-cache-key branch May 19, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants