Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovepixelart committed Dec 5, 2023
1 parent 1f2c00f commit ee606bb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ cache.init(mongoose, {
engine: 'memory',
})

// OR

// Redis example
cache.init(mongoose, {
defaultTTL: '60 seconds',
Expand All @@ -91,6 +93,7 @@ cache.init(mongoose, {
},
})

// Connect to your database
mongoose.connect('mongodb://localhost:27017/my-database')

// Somewhere in your code
Expand Down Expand Up @@ -122,6 +125,15 @@ const books = await Book.aggregate([
},
}
]).cache('1 minute').exec()

// Cache invalidation

// To clear all cache, don't use in production unless you know what you are doing
await cache.clear()

// Instead use custom cache key
const user = await User.findById('61bb4d6a1786e5123d7f4cf1').cache('1 minute', 'some-custom-key').exec()
await cache.clear('some-custom-key')
```

## Check my other projects
Expand Down

0 comments on commit ee606bb

Please sign in to comment.