Skip to content

Commit 028996b

Browse files
author
Joe Podwys
committed
Update README.md
1 parent 4817742 commit 028996b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Public access to the underlying `node_redis` instance
1515
* A more logical API--`.mset()` takes an object of keys and values rather than a comma-separated argument list
1616
* `.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
1718

1819
# Basic Usage
1920

@@ -77,6 +78,12 @@ If you have a redis URL contained in an env variable (in process.env[redisEnv]),
7778

7879
* type: string
7980

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+
8087
## backgroundRefreshInterval
8188

8289
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){
217224
cb(null, response);
218225
}
219226
```
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:
231+
232+
```javascript
233+
var redisMock = require('redis-js');
234+
var rcModule = require('cache-service-redis');
235+
var redisCache = new rcModule({
236+
redisMock: redisMock,
237+
backgroundRefreshInterval: 500
238+
});
239+
```

0 commit comments

Comments
 (0)