Comments (4)
from node-casbin.
@jimcamut see performance optimization docs: https://casbin.org/docs/performance
from node-casbin.
@jimcamut see performance optimization docs: https://casbin.org/docs/performance
@hsluoyz I've essentially done 2 and 3 of the suggestions. I'm also attempting policy subset loading. In other words something like this:
const workspaceEnforcerPromise: { [workspaceId: string]: Promise<Enforcer> } = {};
export async function getWorkspaceEnforcer(workspaceId: string) {
if (!workspaceEnforcerPromise[workspaceId]) {
workspaceEnforcerPromise[workspaceId] = getAdapter()
.then(async adapter => {
const enforcer = await newEnforcer(casbinModel, adapter);
logger.info(`Casbin enforcer initialized with workspace filter ${workspaceId}`);
await enforcer.loadFilteredPolicy({
$or: [
{ ptype: 'p', v1: workspaceId },
{ ptype: 'g', v2: workspaceId },
],
});
return enforcer;
})
.catch(error => {
logger.error(error, `Error initializing Casbin enforcer: ${error.message}`);
workspaceEnforcerPromise[workspaceId] = null;
throw error;
});
}
return workspaceEnforcerPromise[workspaceId];
}
// Using the subset example
async function enforce(...args) {
const enforcer = await getWorkspaceEnforcer(workspaceId);
return enforcer.enforce(...args)
}
Is this the intended usage? I'm seeing a delay of about 13 seconds on my main thread when first loading - and is that expected?
from node-casbin.
@jimcamut you mean you are loading rules from DB for 13 seconds? Then you need to consider it like reading DB slow. Like loading smaller size data, or make your DB near to your application, etc.
from node-casbin.
Related Issues (20)
- Add to Nest.js docs HOT 1
- KeyMatch5 does not match the expected result HOT 1
- [email protected]: The expression-eval npm package is no longer maintained HOT 5
- [feature] ABAC support for EnableAcceptJsonRequest() HOT 2
- enforcer.deleteUser() wiped out all data from `casbin_rule` table HOT 1
- Without enforcer.loadPolicy() Casbin behave unpredictably on mass updates. HOT 1
- [Bug] Can't resolve 'fs' HOT 7
- [bug] When using ‘watcherEx’, deletion does not trigger it; you need to configure a ‘watcher’ for it to work. HOT 2
- [Bug] The lack of a constructor results in the default configuration not taking effect. HOT 3
- addMatchingFunc HOT 2
- usage of addMatchingFunc HOT 2
- [Question] Can the cache stored in memory here be placed in Redis? HOT 3
- Why I can't use enforcer to judge the req using the rbac modle? HOT 1
- [Bug] Policy definition contains 2 different policy sets (p and p2) doesn't work in Casbin editor HOT 4
- escapeAssertion does not respect string literals HOT 3
- Effects are ignored for all policies other than the first one HOT 2
- Fix: Discrepancy between `getAllNamedRoles` function implementation and comments HOT 6
- Replace depricated library [email protected] HOT 2
- Feature Request: Method to Retrieve All Domains for a User or a role HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-casbin.