2.0.2 • Published 3 years ago

@venix/cachified v2.0.2

Weekly downloads
39
License
MIT
Repository
github
Last release
3 years ago

Cachified - A plug and play NestJS Redis powered cache.

Downloads npm bundle size Version

License

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 folder.


Initializing Cachified

example.service.ts

import { Injectable } from '@nestjs/common';
import { Cachified } from '@venix/cachified';

@Injectable()
export class ExampleService {
    @Cachified()
    cachedMethod() {
        return "Hey from cached method"       
    }
}

app.module.ts Using Redis client data

import { Module } from '@nestjs/common';
import { CachifiedModule } from '@venix/cachified';
import { ExampleService } from './example.service.ts';

const isProduction = process.env.NODE_ENV === 'production';  

@Module({
    imports: [
        CachifiedModule.forRoot({
            enabled: isProduction,
            client: {
                host: '127.0.0.1',
                port: 6379,
                db: 0,
                keyPrefix: 'project:'
            }
        })
    ],
    providers: [
        ExampleService
    ]
})
export class ApplicationModule {}

app.module.ts Using pre-defiend redis client

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:'
});

@Module({
    imports: [
        CachifiedModule.forRoot({
            enabled: isProduction,
            client: redisClient
        })
    ],
    providers: [
        ExampleService
    ]
})
export class ApplicationModule {}

If you have any feature requests you would like to be implemented please open an issue.

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.2.1

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago