identity_cache
identity_cache copied to clipboard
Introduce Deferred Parent Cache Expiry
⚠️ I would appreciate help documenting this feature appropriately and preparing a release in an appropriate manner. Thank you in advance!
The case in the tests models the situation this solves for. In summary, if a parent record has three children records which are all deleted, we don't want to expire the parent record cache three times. Once will do, at the end of the operation.
This PR introduces an "escape" for the expiration of a parent's cache. It is currently reliant upon the user of the gem to utilise this functionality safely. Therefore, it is strongly recommended to be used within a transaction.
To introduce the feature we are simply using a class method that wraps the existing code. If this feature has further use, we may choose to build upon this approach in two ways:
- Control it via configuration (rather than this API)
- Handle more cases than parent cache expiry