chore(release): 1.1.1 [skip ci]

## [1.1.1](https://github.com/pycasbin/redis-watcher/compare/v1.1.0...v1.1.1) (2023-04-08)

### Bug Fixes

* compatibility with later casbin patches ([#11](https://github.com/pycasbin/redis-watcher/issues/11)) ([f5dba83](https://github.com/pycasbin/redis-watcher/commit/f5dba836b9397fb6bf8b97b47c81b156ed2ec04f))
2 files changed
tree: 3699563e260b516ea9462e5a13f6f057be815c5b
  1. .github/
  2. casbin_redis_watcher/
  3. examples/
  4. tests/
  5. .coveragerc
  6. .gitignore
  7. .releaserc.json
  8. CHANGELOG.md
  9. LICENSE
  10. pyproject.toml
  11. README.md
  12. requirements.txt
  13. setup.cfg
  14. setup.py
README.md

redis-watcher

tests Coverage Status Version Download Gitter

redis-watcher is the Redis watcher for pycasbin. With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.

Installation

pip install casbin-redis-watcher

Simple Example

import os
import casbin
from casbin_redis_watcher import new_watcher, WatcherOptions

def callback_function(event):
    print("update for remove filtered policy callback, event: {}".format(event))

def get_examples(path):
    examples_path = os.path.split(os.path.realpath(__file__))[0] + "/../examples/"
    return os.path.abspath(examples_path + path)

if __name__ == "main":
    test_option = WatcherOptions()
    test_option.host = "localhost"
    test_option.port = "6379"
    test_option.channel = "test"
    test_option.ssl = False
    test_option.optional_update_callback = callback_function
    w = new_watcher(test_option)
    
    e = casbin.Enforcer(
        get_examples("rbac_model.conf"), get_examples("rbac_policy.csv")
    )
    e.set_watcher(w)
    # then the callback function will be called when the policy is updated.
    e.save_policy()
   

Getting Help

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.