@biorate/ioredis

1.96.0 • Public • Published

IORedis

IORedis connector

Examples:

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { IORedisConnector, IORedisConfig } from '@biorate/ioredis';

class Root extends Core() {
  @inject(IORedisConnector) public connector: IORedisConnector;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<IORedisConnector>(IORedisConnector).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

container.get<IConfig>(Types.Config).merge({
  IORedis: [
    {
      name: 'connection',
      options: {
        host: 'localhost',
        port: 6379,
      },
    },
  ],
});

(async () => {
  const root = container.get<Root>(Root);
  await root.$run();

  await root.connector.current!.set('key', 'value');
  console.log(await root.connector.current!.get('key')); // value
})();

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Readme

Keywords

Package Sidebar

Install

npm i @biorate/ioredis

Weekly Downloads

2

Version

1.96.0

License

MIT

Unpacked Size

132 kB

Total Files

35

Last publish

Collaborators

  • llevkin