chore(release): 1.0.0 [skip ci] # 1.0.0 (2022-07-25) ### Bug Fixes * change the lint config ([22df8c7](https://github.com/pycasbin/redis-watcher/commit/22df8c7ab672ab1bff000ed20720058e783a8e83)) ### Features * add functions to watcher ([#5](https://github.com/pycasbin/redis-watcher/issues/5)) ([705ba31](https://github.com/pycasbin/redis-watcher/commit/705ba31a82ba5661b3fad901726f688af869595c)) * add semantic release, lint and small fix ([b2f0f6c](https://github.com/pycasbin/redis-watcher/commit/b2f0f6c189e7c0e5ec9e6a8781a4b65d75720078)) * build main functions, add unit test and add readme ([#6](https://github.com/pycasbin/redis-watcher/issues/6)) ([416f6e3](https://github.com/pycasbin/redis-watcher/commit/416f6e3596fcac4fa36845670c35d2259756635f))
redis-watcher is the Redis watcher for pycasbin. With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.
pip install casbin-redis-watcher
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.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()
This project is under Apache 2.0 License. See the LICENSE file for the full license text.