This repository has been archived on 2025-03-21. You can view files and clone it, but cannot push or open issues or pull requests.
insiemesalute-3p-nx/apps/ebitemp-api/src/app/modules/keyv/keyv.service.ts

17 lines
515 B
TypeScript

import { createKeyv, KeyvRedisOptions } from '@keyv/redis';
import { Inject, Injectable } from '@nestjs/common';
import { parse, stringify } from 'flatted';
import { keyvConfig, KeyvConfig } from './keyv.config';
@Injectable()
export class KeyvService {
constructor(@Inject(keyvConfig.KEY) private readonly config: KeyvConfig) {}
create(options?: KeyvRedisOptions) {
const keyv = createKeyv(this.config.redis, options);
keyv.serialize = stringify;
keyv.deserialize = parse;
return keyv;
}
}