Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement simple Subscription Caching mechanism using UserDefaults #703

Merged
merged 12 commits into from
Mar 8, 2024

Conversation

afterxleep
Copy link
Collaborator

@afterxleep afterxleep commented Mar 7, 2024

Required:

Task/Issue URL: https://app.asana.com/0/1204099484721401/1206574474409573/f
iOS PR: duckduckgo/iOS#2556
macOS PR: duckduckgo/macos-browser#2359
What kind of version bump will this require?: Minor

Description:

  • Implements mechanism for caching subscription info
  • Caches entitlements
  • Cleans cache on signout.
  • Returns cached entitlements by default (if present)
  • Adds a skipCache parameter to fetchEntitlements to force fetching from the service
  • Posts a Notification only when entitlements change
  • Existing API remains the same. This does not require changes on local implementation

Steps to test this PR:

  1. Purchase a subscription
  2. Confirm that entitlements are returned from cache after first use (Breakpoint here)

Internal references:

Software Engineering Expectations
Technical Design Template

@afterxleep afterxleep marked this pull request as ready for review March 7, 2024 16:50
@afterxleep afterxleep changed the title Implement simple Subscription Cache Service using UserDefaults Implement simple Subscription Caching mechanism using UserDefaults Mar 7, 2024
@afterxleep afterxleep requested a review from miasma13 March 7, 2024 16:58
@afterxleep
Copy link
Collaborator Author

@miasma13 @quanganhdo got some updates...

  1. Made the cache generic so we can not initialize for a specific type
  2. Implemented Apple-like cache policy methods for elegance :bowtie:
  3. Removed cache cleanup on fetch failure
  4. Added entitlements to notification object
  5. Addressed small comments for vars and etc

Copy link
Contributor

@miasma13 miasma13 left a comment

Choose a reason for hiding this comment

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

Really nice job 🥇

@afterxleep afterxleep merged commit 38f51b8 into main Mar 8, 2024
7 checks passed
@afterxleep afterxleep deleted the daniel/subscriptions.entitlements.caching branch March 8, 2024 16:36
samsymons added a commit that referenced this pull request Mar 13, 2024
* main:
  Subscriptions: Implement Caching for Subscription Info (#710)
  add history to ios (#693)
  Reports on toggle protections off (#696)
  Move vpnFirstEnabled and networkPathChange out of VPNSettings (#707)
  Implement simple Subscription Caching mechanism using UserDefaults (#703)
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.

3 participants