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
+20
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@
14
14
* Public access to the underlying `node_redis` instance
15
15
* A more logical API--`.mset()` takes an object of keys and values rather than a comma-separated argument list
16
16
*`.mset()` allows you to set expirations on a per key, per function call, and/or per `cache-service-redis` instance basis (Vanilla `redis` does not let `.mset()` set expirations at all)
17
+
* Built-in [redis mock support](#using-a-redis-mock) for local testing
17
18
18
19
# Basic Usage
19
20
@@ -77,6 +78,12 @@ If you have a redis URL contained in an env variable (in process.env[redisEnv]),
77
78
78
79
* type: string
79
80
81
+
## redisMock
82
+
83
+
If you want to test your `cache-service-redis` implementation, you can pass a redis mock with this key and `cache-service-redis` will consume it for testing purposes. See the [Using A Redis Mock](#using-a-redis-mock) section for a more throrough explanation.
84
+
85
+
* type: object that mocks redis
86
+
80
87
## backgroundRefreshInterval
81
88
82
89
How frequently should all background refresh-enabled keys be scanned to determine whether they should be refreshed. For a more thorough explanation on `background refresh`, see the [Using Background Refresh](#using-background-refresh) section.
@@ -217,3 +224,16 @@ var refresh = function(key, cb){
217
224
cb(null, response);
218
225
}
219
226
```
227
+
228
+
# Using A Redis Mock
229
+
230
+
You're likely to want to test your implementation of `cache-service-redis`. In order to write tests that will run anywhere, you'll need to use a redis mock. I recommend using [redis-js](https://www.npmjs.com/package/redis-js). `cache-service-redis` natively supports mock usage as follows:
0 commit comments