npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rnw-community/nestjs-rxjs-redis

v1.8.2

Published

NestJS RxJS redis

Downloads

29

Readme

NestJS RxJS Redis

NestJS redis wrapper for using with RxJS streams.

npm version npm downloads

TODO

  • [ ] Merge and refactor @nestjs-modules/ioredis into this repo, as it has not been updated for 3+ years.

Configuration

Import NestJSRxJSRedisModule into your module:

import { Module } from '@nestjs/common';
import { NestJSRxJSRedisModule } from '@rnw-community/nestjs-rxjs-redis';

@Module({
    imports: [NestJSRxJSRedisModule],
    providers: [],
    exports: [],
})
export class MyModule {}

Inject NestJSRxJSRedisService into your service:

import { Injectable } from '@nestjs/common';
import { NestJSRxJSRedisService } from '@rnw-community/nestjs-rxjs-redis';

@Injectable()
export class MyService {
    constructor(private readonly redis: NestJSRxJSRedisService) {}
}

Basic operations examples

import { Injectable } from '@nestjs/common';
import { NestJsRxjsLoggerService } from '@rnw-community/nestjs-rxjs-logger';

@Injectable()
export class MyService {
    constructor(private readonly redis: NestJSRxJSRedisService) {}

    setExample$(): Observable<boolean> {
        return this.redis.set$('my-redis-key', 'value', 60, 'Cannot save value');
    }

    getExample$(): Observable<boolean> {
        return this.redis.get$('my-redis-key', 'Cannot get key');
    }

    delExample$(): Observable<boolean> {
        return this.redis.del$('my-redis-key', 'Cannot delete key');
    }

    multipleGetEample$(): Observable<boolean> {
        return this.redis.mget$(['my-redis-key-1', 'my-redis-key-2']);
    }
}

Operator examples

Save

This operator receives a value from RxJS stream, passes it to keyFn handler for generating data-related redis key and converts data to string using toValueFn and. saves this string to redis.

export class MyService {
    saveExample$(): Observable<number> {
        return of(9999).pipe(
            this.redis.save(
                data => `redis-key-${data}`,
                60,
                data => `Cannot save ${data} to redis`
            )
        );
    }
}

Load

This operator receives a key from RxJS stream, passes it to keyFn handler for generating redis key, retrieves a keys from redis and converts data from string using fromValueFn.

export class MyService {
    loadExample$(): Observable<MyType> {
        return of('my-redis-key').pipe(
            this.redis.load<MyType>(
                key => `${key}-modified`,
                key => `Cannot save ${key} to redis`
            )
        );
    }
}

Remove

This operator receives a key from RxJS stream, passes it to keyFn handler for generating redis key and deletes a key in redis.

export class MyService {
    removeExample$(): Observable<string> {
        return of('my-redis-key').pipe(
            this.redis.remove(
                key => `${key}-modified`,
                key => `Cannot remove ${key} from redis`
            )
        );
    }
}

LoadAndSave

This operator loads data from redis and if data is not available executes prepareFn$ handler and saves returned data to redis.

export class MyService {
    loadAndSaveExample$(): Observable<MyType> {
        return of('my-redis-key').pipe(
            this.redis.loadAndSave<MyType>(
                60,
                key => of(9999),
                key => `${key}-modified`
            )
        );
    }
}

License

This library is licensed under The MIT License.