File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -81,15 +81,15 @@ import mongoose from 'mongoose'
81
81
import cache from ' ts-cache-mongoose'
82
82
83
83
// In-memory example
84
- cache .init (mongoose , {
84
+ const instance = cache .init (mongoose , {
85
85
defaultTTL: ' 60 seconds' ,
86
86
engine: ' memory' ,
87
87
})
88
88
89
89
// OR
90
90
91
91
// Redis example
92
- cache .init (mongoose , {
92
+ const instance = cache .init (mongoose , {
93
93
defaultTTL: ' 60 seconds' ,
94
94
engine: ' redis' ,
95
95
engineOptions: {
@@ -134,11 +134,11 @@ const books = await Book.aggregate([
134
134
// Cache invalidation
135
135
136
136
// To clear all cache, don't use in production unless you know what you are doing
137
- await cache .clear ()
137
+ await instance .clear ()
138
138
139
139
// Instead use custom cache key
140
140
const user = await User .findById (' 61bb4d6a1786e5123d7f4cf1' ).cache (' 1 minute' , ' some-custom-key' ).exec ()
141
- await cache .clear (' some-custom-key' )
141
+ await instance .clear (' some-custom-key' )
142
142
```
143
143
144
144
## Check my other projects
You can’t perform that action at this time.
0 commit comments