[ENG-740] 3/6 - Use DSR Cache store for clearing cached DSR data #7482
[ENG-740] 3/6 - Use DSR Cache store for clearing cached DSR data #7482johnewart wants to merge 6 commits intojohnewart/ENG-740/1-dsr-cache-storagefrom
Conversation
This uses the `clear` method on the DSR cache store, which underneath the hood uses `scan` (if needed, will try to use the set-based key index if that particular ID is being tracked). Adds some tests and removes the dependency on get_all_cache_keys_for_privacy_request
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
| from fides.api.util.identity_verification import IdentityVerificationMixin | ||
| from fides.api.util.logger import Pii | ||
| from fides.api.util.logger_context_utils import Contextualizable, LoggerContextKeys | ||
| from fides.common.cache import get_dsr_cache_store |
There was a problem hiding this comment.
get_dsr_cache_store is not defined or exported in fides.common.cache. This import will fail with ImportError.
The function needs to be added to src/fides/common/cache/__init__.py. Based on the usage pattern and test mocking, it should be a context manager like:
| from fides.common.cache import get_dsr_cache_store | |
| from fides.api.util.cache import get_cache | |
| from fides.common.cache import get_dsr_cache_store, DSRCacheStore |
Add to /src/fides/common/cache/__init__.py:
@contextmanager
def get_dsr_cache_store() -> Iterator[DSRCacheStore]:
"""Get a DSR cache store instance using the application Redis cache."""
from fides.api.util.cache import get_cache
redis_client = get_cache()
manager = RedisCacheManager(redis_client)
yield DSRCacheStore(manager)| ) | ||
|
|
||
| def keys(self, pattern): | ||
| import fnmatch |
There was a problem hiding this comment.
importing fnmatch inside method violates custom rule - move to top of module
| import fnmatch | |
| return [k for k in self._data if fnmatch.fnmatch(k, pattern)] |
Add at top of file:
import fnmatchContext Used: Rule from dashboard - Move imports to the top of the module rather than inside functions. Avoid placing imports inside tes... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
@greptileai review |
Greptile SummaryThis PR refactors the privacy request cache clearing logic to use the new Key Changes:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 86557db |
Ticket ENG-2759
Description Of Changes
Uses the DSR cache store to delete cache keys; since the new write path isn't being used this (by design) falls back to doing the same as the existing logic only it uses
SCANinstead ofKEYSwhich is non-blocking. When the writes use the new path then we will update it to use the index instead; this way we can keep current behavior while rolling over to new.Code Changes
clearmethod and adds tests for itSteps to Confirm
No manual steps needed
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works