Merged
Conversation
dthyresson
reviewed
Dec 3, 2022
| return cache(latestCacheKey, () => model.findMany(conditions), rest) | ||
| } | ||
|
|
||
| const deleteCacheKey = async (key: CacheKey) => { |
Contributor
There was a problem hiding this comment.
Perhaps an an alias (or rename) deleteCacheKey to invalidate?
Contributor
Author
There was a problem hiding this comment.
Since both libs called the function delete (and del) I figured it was best to stay with that nomenclature. I know we talk about "invalidating the cache" but I wonder if that's the proper term to use for what we're doing...invalidation sounds like it's still around, it's just not "valid" any more. Whereas memcached and Redis really seem to delete it from memory and it's no longer available...
github-actions Bot
pushed a commit
that referenced
this pull request
Dec 12, 2022
* Adds deleteCacheKey() to exported cache functions * Reorg tests * Remove some comments * Update types, simplify Redis return on del() * Fix double not on promise * Add info block about using a hash of columns in the key
jtoar
pushed a commit
that referenced
this pull request
Dec 12, 2022
* Adds deleteCacheKey() to exported cache functions * Reorg tests * Remove some comments * Update types, simplify Redis return on del() * Fix double not on promise * Add info block about using a hash of columns in the key
dac09
added a commit
that referenced
this pull request
Dec 13, 2022
….com:redwoodjs/redwood into feat/dc-kc-decoupled-auth-setup-improvements * 'feat/dc-kc-decoupled-auth-setup-improvements' of github.com:redwoodjs/redwood: chore(deps): update dependency nx to v15.3.2 (#7114) chore(deps): update dependency redis to v4.5.1 (#7115) fix: add missing deps to cli helpers (#7117) Adds ability to delete a cache entry (#7016) Label override flags for dbAuth generator (#6440) fix(deps): update dependency systeminformation to v5.16.6 (#7108) feat: Generator rollbacks (#6947) fix(deps): update dependency @types/node to v16.18.8 (#7107) chore(deps): update dependency supertokens-node to v12.1.3 (#7105)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the ability to delete a cache entry by its key. This will allow you to be a little more lax in your cache key names if you know you have circumstances where you bust the cache explicitly so that it can be re-built.
Consider an example where you are caching a post by its
id. You currently have no way to bust the cache when the post itself changes in some way. But if you can manually delete the cache entry when updating or deleting a post, you are good to go:Of course this assumes that this service is the only place where a post is updated. If not, you either need to make duplicate
deleteCacheKey()calls, or come up with a key that automatically busts the cache on a post change (like incorporating theupdatedAttimestamp).The
deleteCacheKey()function will returntrueif the key was found and deleted, otherwise it returnsfalse.Thanks for the suggestion @dthyresson!
Closes #7003