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

casbin cache #171

Closed
liergou99 opened this issue Jun 18, 2020 · 7 comments
Closed

casbin cache #171

liergou99 opened this issue Jun 18, 2020 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@liergou99
Copy link

liergou99 commented Jun 18, 2020

The problem with caspin caching is as follows::
1.If the system is load balanced through multiple servers,It is more convenient to store permission data only through the database,If the cache is used, it is easy to cause data inconsistency among multiple servers
2.My system has permission tables and does not want to use sqlx-adapter table.

@GopherJ
Copy link
Member

GopherJ commented Jun 18, 2020

@liergou99

  1. It's a known issue, I have thought about this, to fix this you need to share cache, casbin-rs exports Cache interface, you can implement your own cache using redis.https://github.com/casbin/casbin-rs/blob/master/src/cache/mod.rs
  2. now the table is fixed to: casbin-rules, you can have a forked version to achieve your needs, or if you have an idea on making it supports user-defined table name, let us know. PR is welcome

@GopherJ
Copy link
Member

GopherJ commented Jun 18, 2020

@liergou99 BTW, we have also this repo if you would like to contribute:

https://github.com/casbin-rs/redis-cache

@hsluoyz hsluoyz added the enhancement New feature or request label Jun 19, 2020
@liergou99
Copy link
Author

  1. I modified the sql-adapter. The modified sql-adapter uses the tables in my system and completes a simple test, but the current modified program is highly coupled with my system.
  2. I think it is very useful to cache permission data through redis. I will try to write about redis-cache, but it may take a little longer. On the one hand, I have company work to complete, on the other hand, I need to understand more casbin architecture

@GopherJ
Copy link
Member

GopherJ commented Jun 22, 2020

@hackerchai could you help solving this issue? I know that you are already maybe available

BTW @liergou99 why are you using multiple CachedEnforcer instance?

@hackerchai
Copy link
Member

@hackerchai could you help solving this issue? I know that you are already maybe available

BTW @liergou99 why are you using multiple CachedEnforcer instance?

Get it

@liergou99
Copy link
Author

Enterprise level projects usually use multiple service nodes to achieve load balancing or dynamic expansion. If each node uses its own memory for data caching, data consistency between nodes cannot be guaranteed.

@GopherJ
Copy link
Member

GopherJ commented Aug 16, 2020

It's now https://github.com/casbin-rs/redis-cache, but not published to crates.io yet because it only works with release-v2.0.0 branch

@GopherJ GopherJ closed this as completed Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants