@biorate/redis

1.65.4 • Public • Published

Redis

Redis connector

Examples:

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { RedisConnector, RedisConfig } from '@biorate/redis';

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

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

container.get<IConfig>(Types.Config).merge({
  Redis: [
    {
      name: 'connection',
      options: {
        url: 'redis://localhost: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)

Dependencies (6)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @biorate/redis

    Weekly Downloads

    1

    Version

    1.65.4

    License

    MIT

    Unpacked Size

    210 kB

    Total Files

    33

    Last publish

    Collaborators

    • llevkin