chore(release): 1.6.0 [skip ci] # [1.6.0](https://github.com/officialpycasbin/redis-watcher/compare/v1.5.0...v1.6.0) (2025-05-09) ### Features * fix CI release branch ([#4](https://github.com/officialpycasbin/redis-watcher/issues/4)) ([a9b86f1](https://github.com/officialpycasbin/redis-watcher/commit/a9b86f1226d39bc4f9182ab8662cc32eb49b44e6))
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 redis-watcher
import os import casbin from 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()
This project is under Apache 2.0 License. See the LICENSE file for the full license text.