Closed lucasrolim-intuitive closed 5 years ago
@lucasrolim-intuitive , how many policy rules do you have? Which adapter are you using?
I have around 20 rules type (p) and 250 of type (g). I´m using the sequelizer adapter.
async createEnforcer(){
const database = await SequelizeAdapter.newAdapter(`mysql://${db_credentials.user}:${db_credentials.password}@${db_credentials.host}:${db_credentials.port}/${db_credentials.name}`, true);
this.enforcer = await Enforcer.newEnforcer('casbin/model.conf', database);
await this.enforcer.loadPolicy();
}
@lucasrolim-intuitive Sequelizer Adapter supports the AutoSave feature, you do not need to call await this.enforcer.savePolicy()
manually, addNamedGroupingPolicy()
will automatically store the new policy rule into DB.
The savePolicy()
in this adapter doesn't use bulk operation, it saves all policy rules (20 + 250) one by one, that's why it is slow. You can also choose to improve this adapter with bulk-style savePolicy operation
Thank you!
I'm using MySQL and having some troubles with the time to add a new user policy. This is taking around 6 seconds. Is this the expected time?
My express.js route
Function to insert a new user role.