Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

Commit 97b1cff

Browse files
docs(README): fix typo && format (#23)
1 parent 060796b commit 97b1cff

File tree

1 file changed

+13
-48
lines changed

1 file changed

+13
-48
lines changed

README.md

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ module.exports = {
4747

4848
|Name|Type|Default|Description|
4949
|:--:|:--:|:-----:|:----------|
50-
|**`cacheKey`**|`{Function(options, request) -> {String}}`|`undefined`|Allows you to override default cache key generator.|
50+
|**`cacheKey`**|`{Function(options, request) -> {String}}`|`undefined`|Allows you to override default cache key generator|
5151
|**`cacheDirectory`**|`{String}`|`path.resolve('.cache-loader')`|Provide a cache directory where cache items should be stored (used for default read/write implementation)|
52-
|**`cacheIdentifier`**|`{String}`|`cache-loader:{version} {process.env.NODE_ENV}`|Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders. (used for default read/write implementation)|
53-
|**`write`**|`{Function(cacheKey, data, callback) -> {void}}`|`undefined`|Allows you to override default write cache data to file (e.g. Redis, memcached).|
54-
|**`read`**|`{Function(cacheKey, callback) -> {void}}`|`undefined`|Allows you to override default read cache data from file.|
52+
|**`cacheIdentifier`**|`{String}`|`cache-loader:{version} {process.env.NODE_ENV}`|Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation)|
53+
|**`write`**|`{Function(cacheKey, data, callback) -> {void}}`|`undefined`|Allows you to override default write cache data to file (e.g. Redis, memcached)|
54+
|**`read`**|`{Function(cacheKey, callback) -> {void}}`|`undefined`|Allows you to override default read cache data from file|
5555

5656
<h2 align="center">Examples</h2>
5757

@@ -73,40 +73,16 @@ module.exports = {
7373
}
7474
```
7575

76-
### `Options`
76+
### `Database Integration`
7777

7878
**webpack.config.js**
7979
```js
80-
module.exports = {
81-
module: {
82-
rules: [
83-
{
84-
test: /\.js$/,
85-
use: [
86-
{
87-
loader: 'cache-loader',
88-
options: {
89-
cacheDirectory: path.resolve('.cache')
90-
}
91-
},
92-
'babel-loader'
93-
],
94-
include: path.resolve('src')
95-
}
96-
]
97-
}
98-
}
99-
```
100-
101-
### Database Intergration
102-
103-
**webpack.config.js**
104-
```js
105-
const redis = require('redis'); // Or different database client - memcached, mongodb, ...
80+
// Or different database client - memcached, mongodb, ...
81+
const redis = require('redis');
10682
const crypto = require('crypto');
10783

10884
// ...
109-
// ... connect to client
85+
// connect to client
11086
// ...
11187

11288
const BUILD_CACHE_TIMEOUT = 24 * 3600; // 1 day
@@ -115,16 +91,13 @@ function digest(str) {
11591
return crypto.createHash('md5').update(str).digest('hex');
11692
}
11793

118-
/**
119-
* Generate own cache key
120-
*/
94+
// Generate own cache key
12195
function cacheKey(options, request) {
12296
return `build:cache:${digest(request)}`;
12397
}
12498

125-
/**
126-
* Read data from database and parse them
127-
*/
99+
100+
// Read data from database and parse them
128101
function read(key, callback) {
129102
client.get(key, (err, result) => {
130103
if (err) {
@@ -144,9 +117,8 @@ function read(key, callback) {
144117
});
145118
}
146119

147-
/**
148-
* Write data to database under cacheKey
149-
*/
120+
121+
// Write data to database under cacheKey
150122
function write(key, data, callback) {
151123
client.set(key, JSON.stringify(data), 'EX', BUILD_CACHE_TIMEOUT, callback);
152124
}
@@ -200,13 +172,6 @@ module.exports = {
200172
Joshua Wiens
201173
</a>
202174
</td>
203-
<td align="center">
204-
<a href="https://github.com/sapegin">
205-
<img width="150" height="150" src="https://github.com/sapegin.png?v=3&s=150">
206-
</br>
207-
Artem Sapegin
208-
</a>
209-
</td>
210175
<td align="center">
211176
<a href="https://github.com/michael-ciniawsky">
212177
<img width="150" height="150" src="https://github.com/michael-ciniawsky.png?v=3&s=150">

0 commit comments

Comments
 (0)