Skip to content

feat: new cache logic#2

Draft
duyhungtnn wants to merge 10 commits intoupdate-12-26-2024from
feat/new-cache-logic
Draft

feat: new cache logic#2
duyhungtnn wants to merge 10 commits intoupdate-12-26-2024from
feat/new-cache-logic

Conversation

@duyhungtnn
Copy link
Collaborator

No description provided.

Added logic to detect user ID changes and force resubscription to chat list updates when the account changes. This ensures chat list updates are correctly handled after switching users.
Introduced a static property `didChangedUserID` to indicate when the user ID has changed. Updated the `set(userID:)` method to set this flag when the user ID changes, and added `setCacheHasBeenUpdated()` to reset the flag after cache updates.
Replaced the concurrent access queue with a serial queue to protect settingsCache. Updated the settings property to ensure user ID consistency and cache validity by accessing TGUserController within a lock and reading from disk inside the lock.
Updated indentation and whitespace throughout CloudVeilSecurityController.swift to improve code readability and maintain consistent formatting. No functional changes were made.

feat: upgrade cache key to include user and organization ID

Enhanced the caching system to use a composite key of user ID and organization ID for improved cache isolation and correctness when users switch organizations. Added orgId support to TGUserModel, updated TGUserController to manage orgId and its change flag, and modified CloudVeilSecurityController to use the new composite cache key. All changes maintain thread safety and do not break existing code.

feat: add orgID support to user and settings controllers

Introduces orgID tracking in TGUserController, including change detection and setter. Updates CloudVeilSecurityController to use orgID in cache key and cache validation, ensuring settings are correctly scoped per user and organization.

refactor: saveSettings to support per-user/org cache

Updated saveSettings to accept a user ID and use a cache key based on both user and organization IDs. The method now loads and merges settings from the correct disk cache, and only updates the in-memory cache if the user and org IDs match the current user. This improves multi-user and multi-organization support for settings caching.
Added orgId property to TGSettingsRequest and updated CloudVeilSecurityController to use orgId when saving settings to ensure correct cache key per user and organization. This change helps maintain accurate settings cache for users across different organizations.
@duyhungtnn duyhungtnn self-assigned this Dec 31, 2025
Added detailed log statements to track settings access and cache updates, including user and org IDs and cache validity. Logging now clarifies when the settings cache is updated or not due to user/org mismatches, aiding debugging and monitoring.
Introduced a private withSettings accessor to ensure thread-safe access to settingsCache. Replaced repetitive accessQueue.sync blocks in computed properties with this new helper for improved code clarity and maintainability.
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