0.0.2 • Published 1 year ago

gadin-redis v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Description

Redis is an open source, in-memory data structure store used as a database, cache, message broker, and streaming engine.

You can to use gadin-redis package easily and setup it.

Usage

Step 1: Installation

npm install gadin-redis

wait for the installation to finish.

Step 2: Module initialization

You've added below code in your root module:

@Module({
    imports: [
        RedisModule.forRoot({
            credentials: {
                host: 'host',
                port: 6379,
                username:'user',
                password:'pass'
            }
        })
    ],
    controllers: [AppController],
    providers: [AppService],
})
export class AppModule {
}

Notice

The username and password are optional.

Step 3: Use in Services

You've to inject RedisClient in your service and use redis methods like below:

export class AppService{
    constructor(@Inject(REDIS) private redis: RedisClient) {
    }

    async test() {
        await this.redis.set("key", "value")
    }
}

Hint

Import RedisClinet and REDIS from the gadin-redis

Author

Mohammad Sardari

License

MIT License