Skip to content

About

Redis integration for AsenaJS on Bun: injectable @redis service client, multi-pod WebSocket transport and Redis Streams microservice transport.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

@asenajs/asena-redis

Version License: MIT Bun Version

Redis integration for AsenaJS — a @Redis service client, a multi-pod WebSocket transport and a Redis Streams microservice transport.

Requirements: Bun 1.4+, @asenajs/asena 0.11+.

Installation

bun add @asenajs/asena-redis

Quick Start

import { Redis, AsenaRedisService } from '@asenajs/asena-redis';

@Redis({ config: { url: 'redis://localhost:6379' }, name: 'AppRedis' })
export class AppRedis extends AsenaRedisService {}

Asena discovers it, connects on start and disconnects on stop. Inject it anywhere:

import { Service } from '@asenajs/asena/decorators';
import { Inject } from '@asenajs/asena/decorators/ioc';

@Service()
export class GreetingService {

  @Inject('AppRedis')
  private redis: AppRedis;

  async greet(name: string): Promise<string> {
    await this.redis.set(`greeting:${name}`, `Hello, ${name}`, 60);

    return (await this.redis.get(`greeting:${name}`)) ?? '';
  }

}

Documentation

Full documentation: asena.sh/docs/packages/redis

Contributing

Contributions are welcome! Submit a Pull Request on GitHub.

License

MIT

Support

Issues or questions? Open an issue on GitHub.

About

Redis integration for AsenaJS on Bun: injectable @redis service client, multi-pod WebSocket transport and Redis Streams microservice transport.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages