You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+74-3
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ See the [Express.js cache-manager example app](https://github.com/BryanDonovan/n
51
51
52
52
## Overview
53
53
54
-
First, it includes a `wrap` function that lets you wrap any function in cache.
54
+
**First**, it includes a `wrap` function that lets you wrap any function in cache.
55
55
(Note, this was inspired by [node-caching](https://github.com/mape/node-caching).)
56
56
This is probably the feature you're looking for. As an example, where you might have to do this:
57
57
@@ -82,20 +82,22 @@ function getCachedUser(id, cb) {
82
82
}
83
83
```
84
84
85
-
Second, node-cache-manager features a built-in memory cache (using [node-lru-cache](https://github.com/isaacs/node-lru-cache)),
85
+
**Second**, node-cache-manager features a built-in memory cache (using [node-lru-cache](https://github.com/isaacs/node-lru-cache)),
86
86
with the standard functions you'd expect in most caches:
87
87
88
88
set(key, val, {ttl: ttl}, cb) // * see note below
89
89
get(key, cb)
90
90
del(key, cb)
91
+
mset(key1, val1, key2, val2, {ttl: ttl}, cb) // set several keys at once
92
+
mget(key1, key2, key3, cb) // get several keys at once
91
93
92
94
// * Note that depending on the underlying store, you may be able to pass the
93
95
// ttl as the third param, like this:
94
96
set(key, val, ttl, cb)
95
97
// ... or pass no ttl at all:
96
98
set(key, val, cb)
97
99
98
-
Third, node-cache-manager lets you set up a tiered cache strategy. This may be of
100
+
**Third**, node-cache-manager lets you set up a tiered cache strategy. This may be of
99
101
limited use in most cases, but imagine a scenario where you expect tons of
100
102
traffic, and don't want to hit your primary cache (like Redis) for every request.
101
103
You decide to store the most commonly-requested data in an in-memory cache,
@@ -105,6 +107,8 @@ aren't as common as the ones you want to store in memory. This is something
105
107
node-cache-manager handles easily and transparently.
106
108
107
109
110
+
**Fourth**, it allows you to get and set multiple keys at once for caching store that support it. This means that when getting muliple keys it will go through the different caches starting from the highest priority one (see multi store below) and merge the values it finds at each level.
111
+
108
112
## Usage Examples
109
113
110
114
See examples below and in the examples directory. See ``examples/redis_example`` for an example of how to implement a
0 commit comments