Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add basic support for custom cache providers #5309

Merged
merged 5 commits into from
Jan 22, 2020
Merged

feat: Add basic support for custom cache providers #5309

merged 5 commits into from
Jan 22, 2020

Conversation

justblender
Copy link
Contributor

As of right now, TypeORM only allows to use built-in cache providers, this pull request adds an option to specify a custom cache provider (that should implement QueryResultCache spec) in the ConnectionOptions object:

await createConnection({
  // ...all of the required options for establishing connection

  cache: {
    cacheProvider(connection) {
      return new MockQueryResultCache(connection);
    }
  }
});

/**
* Factory function for custom cache providers that implement QueryResultCache.
*/
readonly cacheProvider?: (connection: Connection) => QueryResultCache;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename it to just "provider". We already have a "cache" word in a parent.

@pleerock
Copy link
Member

Thanks for contribution! Can you please add some test that will check this functionality and docs to describe it for others

@justblender
Copy link
Contributor Author

Smh, made a typo in the commit name.

@pleerock, I've added information in the docs and renamed the property, but I'm not used to write the tests. 😞

@pleerock
Copy link
Member

Its never too late to learn :) Just copy paste exist test, replace few lines of code and it work.

@pleerock pleerock merged commit 6c6bde7 into typeorm:master Jan 22, 2020
@pleerock
Copy link
Member

Thanks!

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.

None yet

2 participants