@casbin/redis-watcher
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Redis-watcher

Redis watcher for node-casbin based on ioredis.

Installation

# NPM
npm install --save @casbin/redis-watcher

# Yarn
yarn add @casbin/redis-watcher

Note: redis-watcher has been deprecated on NPM.

Example

Using Redis:

import { RedisWatcher } from '@casbin/redis-watcher';
import { newEnforcer } from 'casbin';

// Initialize the watcher, see https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
const watcher = await RedisWatcher.newWatcher('redis://localhost:6379/5');

// Initialize the enforcer.
const enforcer = await newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv');

enforcer.setWatcher(watcher);

Using Redis cluster:

import { RedisWatcher } from '@casbin/redis-watcher';
import { newEnforcer } from 'casbin';

// Initialize the watcher, see https://github.com/luin/ioredis/blob/master/API.md#new-clusterstartupnodes-options.
const watcher = await RedisWatcher.newWatcherWithCluster([{ port: 7000, host: 'localhost' }]);

// Initialize the enforcer.
const enforcer = await newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv');

enforcer.setWatcher(watcher);

Readme

Keywords

none

Package Sidebar

Install

npm i @casbin/redis-watcher

Homepage

casbin.org

Weekly Downloads

2,653

Version

1.0.2

License

none

Unpacked Size

23.2 kB

Total Files

9

Last publish

Collaborators

  • chalin
  • hsluoyz