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

0.0.2 • Public • Published

Mollitia


Mollitia Icon

Mollitia - Redis Addon

The Mollitia Redis addon adds redis for some modules of every circuit. The list of modules coming with redis support are Ratelimit, SlidingCountBreaker and SlidingTimeBreaker.

📄 Documentation

Please check out the official documentation to get started using Mollitia, visit genesys.github.io/mollitia.

⚙️ Installation

npm install --save @mollitia/redis

🚀 Usage

// Imports the library
import * as Mollitia from 'mollitia';
import { RedisAddon } from '@mollitia/redis';
// Adds the Redis addon to Mollitia
Mollitia.use(new RedisAddon({
  host: <Redis hostName>,
  port: <Redis Port>,
  password: <Redis Password>
}));
// Creates the module that will be used in your circuit, using Redis
// Redis is only applicable for Modules:
//  - Ratelimit
//  - SlidingCountBreaker
//  - SlidingTimeBreaker
const rateLimit = new Mollitia.Ratelimit({
  name: 'myRateLimit',
  limitForPeriod: 2,
  limitPeriod: 20000,
  redis: {
    // Setting redis.use to true indicates Redis should be used
    use: true
  }
};
// Creates a circuit
const myCircuit = new Mollitia.Circuit({
  // Initializes a circuit with a handler
  func: yourFunction,
  options: { 
    modules: [ 
      rateLimit 
    ]
  }
});
// This will execute yourFunction('dummy')
await myCircuit.execute('dummy');

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.2161latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.2161

Package Sidebar

Install

npm i @mollitia/redis

Weekly Downloads

161

Version

0.0.2

License

MIT

Unpacked Size

13.8 kB

Total Files

6

Last publish

Collaborators

  • cadgerfeast
  • tichon29