chore(release): 1.7.0 [skip ci]

# [1.7.0](https://github.com/officialpycasbin/redis-watcher/compare/v1.6.0...v1.7.0) (2025-08-15)

### Features

* switch from casbin to pycasbin ([#5](https://github.com/officialpycasbin/redis-watcher/issues/5)) ([4130314](https://github.com/officialpycasbin/redis-watcher/commit/4130314d66907c05ab6cf0514e1323c59ceaa29d))
2 files changed
tree: 93889c0297d342bdac6fa40670e39f715c6c10d8
  1. .github/
  2. examples/
  3. redis_watcher/
  4. tests/
  5. .coveragerc
  6. .gitignore
  7. .releaserc.json
  8. CHANGELOG.md
  9. LICENSE
  10. package.json
  11. pyproject.toml
  12. README.md
  13. requirements.txt
README.md

redis-watcher

GitHub Action Coverage Status Version PyPI - Wheel Pyversions Download Discord

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 redis-watcher

Simple Example

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()
   

Getting Help

License

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