Remove lodash-es dependency by locally implementing the case functions used by cache key (next branch)#52
Open
pmosconi wants to merge 1 commit into
Open
Remove lodash-es dependency by locally implementing the case functions used by cache key (next branch)#52pmosconi wants to merge 1 commit into
pmosconi wants to merge 1 commit into
Conversation
…s used by cache key
Owner
|
Hi @pmosconi, I have been thinking about this change and was wondering if it is the right thing to do, to maintain this within the core codebase. I am still not sure, but here is my thought: It would be better to give the users the ability to bring their own string transformation function, with no transformations applied by default. In the example, we can show one with something like lodash.snakecase. Example: import snakeCase from 'lodash.snakecase';
const config: CacheConfig = {
ttl: 60, // Default Time-to-live for caching in seconds
stale: 30, // Default Stale time after ttl in seconds
auto, // Auto-caching options (configured above)
logger, // Logger for cache events (configured above)
transformer: {
// Custom serialize and deserialize function for additional functionality if required
deserialize: data => SuperJSON.parse(data),
serialize: data => SuperJSON.stringify(data),
},
type: 'JSON', // Redis cache type, whether you prefer the data to be stored as JSON or STRING in Redis
cacheKey: { // Inbuilt cache key configuration
caseTransformer: snakeCase, // Provide a transformation function which accepts the raw string and returns the transformed string
delimiter: '*', // Delimiter for keys (default value: ':')
prefix: 'awesomeness', // Cache key prefix (default value: 'prisma')
},
};This is just an example, and I haven't tested it, but this is the thought process. If you would like to discuss this or the other changes coming up in v3, feel free to reach out to me on Discord (ID yxx4c). |
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.
Hi @yxx4c ,
as you suggested, this is the PR for the next branch.
I'd like to thank you for the hard work you put in creating and maintaining this package.
Regarding the breaking change about the returned object, I have some thoughts based on my use cases, but I am going to open an issue for discussion because it doesn't belong here.