@venix/cachified
Version:
A plug and play NestJS redis cache for intensive functions.
88 lines (74 loc) • 2.69 kB
Markdown
# Cachified - A plug and play NestJS Redis powered cache.
[](https://www.npmjs.com/package/@venix/cachified)
[](https://www.npmjs.com/package/@venix/cachified)
[](https://www.npmjs.com/package/@venix/cachified)
[](https://www.npmjs.com/package/@venix/cachified)
---
Cachified is an easy to use, redis-powered caching library that allows you to quickly cache your functions using TypeScript decorators.
It allows you to cache functions with a one line addition to your code.
A simple but descriptive example on how to use Cachified can be found in the [example](https://github.com/widgetbot-io/cachified/tree/master/example) folder.
---
## Initializing Cachified
### example.service.ts
```ts
import { Injectable } from '@nestjs/common';
import { Cachified } from '@venix/cachified';
export class ExampleService {
cachedMethod() {
return "Hey from cached method"
}
}
```
### app.module.ts Using Redis client data
```ts
import { Module } from '@nestjs/common';
import { CachifiedModule } from '@venix/cachified';
import { ExampleService } from './example.service.ts';
const isProduction = process.env.NODE_ENV === 'production';
export class ApplicationModule {}
```
### app.module.ts Using pre-defiend redis client
```ts
import { Module } from '@nestjs/common';
import { CachifiedModule } from '@venix/cachified';
import * as IORedis from 'ioredis';
import { ExampleService } from './example.service.ts';
const isProduction = process.env.NODE_ENV === 'production';
const redisClient = new IORedis({
host: '127.0.0.1',
port: 6379,
db: 0,
keyPrefix: 'project:'
});
export class ApplicationModule {}
```
If you have any feature requests you would like to be implemented please [open an issue](https://github.com/widgetbot-io/cachified/issues).