Drop Node.js 18 from CI, only test on Node.js 20

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
1 file changed
tree: d5343c8d062c09ccd9df005542adc2ae8daa195a
  1. .github/
  2. examples/
  3. src/
  4. test/
  5. .gitignore
  6. .prettierrc
  7. .releaserc.json
  8. CHANGELOG.md
  9. jest.config.js
  10. LICENSE
  11. package.json
  12. README.md
  13. tsconfig.json
  14. tslint.json
  15. yarn.lock
README.md

Redis-watcher

NPM version NPM download ci Coverage Status Discord

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