https://github.com/chqrd/nest-redis
Redis-Client-Module for NestJS
https://github.com/chqrd/nest-redis
nestjs redis
Last synced: about 2 months ago
JSON representation
Redis-Client-Module for NestJS
- Host: GitHub
- URL: https://github.com/chqrd/nest-redis
- Owner: chqrd
- Created: 2024-12-17T09:54:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-17T10:17:36.000Z (over 1 year ago)
- Last Synced: 2025-04-04T12:52:02.076Z (about 1 year ago)
- Topics: nestjs, redis
- Language: TypeScript
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nest-redis
This NestJS module adds a Redis connection to your project.
## Installation
```typescript
import { RedisModule } from "@chqrd/nest-redis";
import { Module } from "@nestjs/common";
@Module({
imports: [
RedisModule.registerAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (config) => ({ url: config.getOrThrow("REDIS_URL", "redis://localhost:6379") }),
}),
],
})
export class AppModule {}
```
```typescript
@Injectable()
export class RequestService {
constructor(private readonly redis: RedisService) {}
async getValue() {
return await this.redis.client.get("my_key");
}
}
```
### Project setup
```bash
$ npm install
```
### Compile and run the project
```bash
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
```