billcobbler / casbin-redis-watcher

Redis watcher for Casbin https://github.com/casbin/casbin
Apache License 2.0
19 stars 23 forks source link

Casbin Redis Watcher update by re-loading the whole casbin policy table #22

Open bingmwu opened 3 years ago

bingmwu commented 3 years ago

We are using Casbin Redis Watcher to help synch-up the policies among different Casbin nodes. The way the Watcher is implemented is to re-load the whole policy table during update. This could be really slow if the size of the table grows to 1 million to 10 million records, which is the size of policy we are seeing to grow into. Is there a better way to synch-up the policies among nodes, using the Watcher? Or if the Dispatcher is only viable alternative?

hsluoyz commented 3 years ago

@bingmwu you can use WatcherEx: https://casbin.org/docs/en/watchers#watcherex

hsluoyz commented 3 years ago

@billcobbler

bingmwu commented 3 years ago

@hsluoyz So we will need to do our own implementation for watcherEx interface, since there is no implementation yet? Just to confirm. Thanks.

hsluoyz commented 3 years ago

@bingmwu yes, can you make a PR to implement it?

bingmwu commented 3 years ago

@hsluoyz we looked at the WatcherEx, but not sure how to access the in-memory model of enforcer, from a WatcherEx. What we need is to update the in-memory model, without saving the policies to the database through JDBC adaptor, when the watcher got an updated policy event.

hsluoyz commented 3 years ago

@bingmwu we will implement the Redis WatcherEx: https://github.com/casbin/redis-watcher/issues/1