nestjs-ioredis | IORedis module for Nest | Web Framework library
kandi X-RAY | nestjs-ioredis Summary
kandi X-RAY | nestjs-ioredis Summary
Integrates IORedis with Nest.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nestjs-ioredis
nestjs-ioredis Key Features
nestjs-ioredis Examples and Code Snippets
Community Discussions
Trending Discussions on nestjs-ioredis
QUESTION
I am using Redis to cache queries inside TypeOrm.
but the problem is, TypeOrm and Redis package is opening the separate connection, i just want to reuse the same connection for both.
this is typeorm config:
...ANSWER
Answered 2020-Aug-25 at 14:29After some digging in the TypeORM code base I came across two solutions (wiil one the other is a bit hacky and my case issues)
ORM CustomQueryResultCacheAccording to the doc, you can implement your own cache handler see: https://github.com/typeorm/typeorm/blob/master/docs/caching.md.
This is the better but harder solution due to the Interface that need to be implemented https://github.com/typeorm/typeorm/blob/master/src/cache/QueryResultCache.ts
In addition, you will need you register the TypeOrmModule with forRootAsync to first be able to connect to Redis.
Hacky fun timesAccording to the code base, you should be able to access the Redise client (connection) that TypeORM is creating.
On the type ORM connection
there is a member called connection.queryResultCache
for managing the cache.
But furthermore there is a member name client
on the queryResultCache (connection.queryResultCache.client
)
See TypeORM redis Cache implamatation: https://github.com/typeorm/typeorm/blob/master/src/cache/RedisQueryResultCache.ts
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nestjs-ioredis
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page