Skip to content

Commit 81b3fd9

Browse files
claudiahdzisaacs
authored andcommittedFeb 17, 2020
docs: update options info
PR-URL: #31 Credit: @claudiahdz Close: #31 Reviewed-by: @isaacs
1 parent 57d11bc commit 81b3fd9

File tree

1 file changed

+63
-9
lines changed

1 file changed

+63
-9
lines changed
 

‎README.md

+63-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ just as easily be used on its own.
3333
* Writing
3434
* [`put`](#put-data)
3535
* [`put.stream`](#put-stream)
36-
* [`put*` opts](#put-options)
3736
* [`rm.all`](#rm-all)
3837
* [`rm.entry`](#rm-entry)
3938
* [`rm.content`](#rm-content)
@@ -92,7 +91,7 @@ cacache.get.byDigest(cachePath, integrityHash).then(data => {
9291
* Lockless, high-concurrency cache access
9392
* Streaming support
9493
* Promise support
95-
* Pretty darn fast -- sub-millisecond reads and writes including verification
94+
* Fast -- sub-millisecond reads and writes including verification
9695
* Arbitrary metadata storage
9796
* Garbage collection and additional offline verification
9897
* Thorough test coverage
@@ -201,6 +200,8 @@ A sub-function, `get.byDigest` may be used for identical behavior, except lookup
201200
will happen by integrity hash, bypassing the index entirely. This version of the
202201
function *only* returns `data` itself, without any wrapper.
203202

203+
See: [options](#get-options)
204+
204205
##### Note
205206

206207
This function loads the entire cache entry into memory before returning it. If
@@ -242,6 +243,8 @@ A sub-function, `get.stream.byDigest` may be used for identical behavior,
242243
except lookup will happen by integrity hash, bypassing the index entirely. This
243244
version does not emit the `metadata` and `integrity` events at all.
244245

246+
See: [options](#get-options)
247+
245248
##### Example
246249

247250
```javascript
@@ -328,12 +331,33 @@ cacache.get.hasContent(cachePath, 'sha521-NOT+IN/CACHE==').then(console.log)
328331
false
329332
```
330333

334+
##### <a name="get-options"></a> Options
335+
336+
##### `opts.integrity`
337+
If present, the pre-calculated digest for the inserted content. If this option
338+
is provided and does not match the post-insertion digest, insertion will fail
339+
with an `EINTEGRITY` error.
340+
341+
##### `opts.memoize`
342+
343+
Default: null
344+
345+
If explicitly truthy, cacache will read from memory and memoize data on bulk read. If `false`, cacache will read from disk data. Reader functions by default read from in-memory cache.
346+
347+
##### `opts.size`
348+
If provided, the data stream will be verified to check that enough data was
349+
passed through. If there's more or less data than expected, insertion will fail
350+
with an `EBADSIZE` error.
351+
352+
331353
#### <a name="put-data"></a> `> cacache.put(cache, key, data, [opts]) -> Promise`
332354

333355
Inserts data passed to it into the cache. The returned Promise resolves with a
334356
digest (generated according to [`opts.algorithms`](#optsalgorithms)) after the
335357
cache entry has been successfully written.
336358

359+
See: [options](#put-options)
360+
337361
##### Example
338362

339363
```javascript
@@ -353,6 +377,8 @@ Stream](https://nodejs.org/api/stream.html#stream_writable_streams) that inserts
353377
data written to it into the cache. Emits an `integrity` event with the digest of
354378
written contents when it succeeds.
355379

380+
See: [options](#put-options)
381+
356382
##### Example
357383

358384
```javascript
@@ -365,9 +391,7 @@ request.get(
365391
)
366392
```
367393

368-
#### <a name="put-options"></a> `> cacache.put options`
369-
370-
`cacache.put` functions have a number of options in common.
394+
##### <a name="put-options"></a> Options
371395

372396
##### `opts.metadata`
373397

@@ -382,7 +406,7 @@ with an `EBADSIZE` error.
382406
##### `opts.integrity`
383407

384408
If present, the pre-calculated digest for the inserted content. If this option
385-
if provided and does not match the post-insertion digest, insertion will fail
409+
is provided and does not match the post-insertion digest, insertion will fail
386410
with an `EINTEGRITY` error.
387411

388412
`algorithms` has no effect if this option is present.
@@ -415,6 +439,11 @@ cache.
415439
Reading from disk data can be forced by explicitly passing `memoize: false` to
416440
the reader functions, but their default will be to read from memory.
417441

442+
##### `opts.tmpPrefix`
443+
Default: null
444+
445+
Prefix to append on the temporary directory name inside the cache's tmp dir.
446+
418447
#### <a name="rm-all"></a> `> cacache.rm.all(cache) -> Promise`
419448

420449
Clears the entire cache. Mainly by blowing away the cache directory itself.
@@ -478,6 +507,8 @@ permissions.
478507
If you want automatic cleanup of this directory, use
479508
[`tmp.withTmp()`](#with-tpm)
480509

510+
See: [options](#tmp-options)
511+
481512
##### Example
482513

483514
```javascript
@@ -517,6 +548,8 @@ promise completes.
517548
The same caveats apply when it comes to managing permissions for the tmp dir's
518549
contents.
519550

551+
See: [options](#tmp-options)
552+
520553
##### Example
521554

522555
```javascript
@@ -527,6 +560,13 @@ cacache.tmp.withTmp(cache, dir => {
527560
})
528561
```
529562

563+
##### <a name="tmp-options"></a> Options
564+
565+
##### `opts.tmpPrefix`
566+
Default: null
567+
568+
Prefix to append on the temporary directory name inside the cache's tmp dir.
569+
530570
#### <a name="integrity"></a> Subresource Integrity Digests
531571

532572
For content verification and addressing, cacache uses strings following the
@@ -582,10 +622,24 @@ When it's done, it'll return an object with various stats about the verification
582622
process, including amount of storage reclaimed, number of valid entries, number
583623
of entries removed, etc.
584624

585-
##### Options
625+
##### <a name="verify-options"></a> Options
626+
627+
##### `opts.concurrency`
628+
629+
Default: 20
586630

587-
* `opts.filter` - receives a formatted entry. Return false to remove it.
588-
Note: might be called more than once on the same entry.
631+
Number of concurrently read files in the filesystem while doing clean up.
632+
633+
##### `opts.filter`
634+
Receives a formatted entry. Return false to remove it.
635+
Note: might be called more than once on the same entry.
636+
637+
##### `opts.log`
638+
Custom logger function:
639+
```
640+
log: { silly () {} }
641+
log.silly('verify', 'verifying cache at', cache)
642+
```
589643

590644
##### Example
591645

0 commit comments

Comments
 (0)
Please sign in to comment.