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: improve performance of AddPolicies #62

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

ishikawa-pro
Copy link
Contributor

Summary:
Improve Performance of AddPolicies in MongoDB Adapter

Description:
This Pull Request aims to enhance the performance of the AddPolicies function in the Casbin MongoDB adapter. The current implementation of AddPolicies inserts each policy rule using the InsertOne method.
However, inserting multiple lines in a single operation is more efficient. Therefore, this update refactors AddPolicies to utilize InsertMany, significantly reducing the number of database operations and potentially improving overall performance for adding multiple policies.

Changes:

  • Changed the lines slice to a slice of interface{} to accommodate the requirements of the InsertMany method.
  • Replaced the InsertOne method with InsertMany for inserting multiple policy lines in a single database call.

@CLAassistant
Copy link

CLAassistant commented Jan 11, 2024

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

Coverage Status

coverage: 82.636% (-0.04%) from 82.672%
when pulling 97fd7cf on ishikawa-pro:improve-add-policies
into e87187c on casbin:master.

@hsluoyz hsluoyz changed the title Improve Performance of AddPolicies feat: improve performance of AddPolicies Jan 11, 2024
@hsluoyz hsluoyz merged commit 8560937 into casbin:master Jan 11, 2024
4 of 5 checks passed
Copy link

🎉 This PR is included in version 3.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@ishikawa-pro ishikawa-pro deleted the improve-add-policies branch January 11, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants