@@ -33,7 +33,6 @@ just as easily be used on its own.
33
33
* Writing
34
34
* [ ` put ` ] ( #put-data )
35
35
* [ ` put.stream ` ] ( #put-stream )
36
- * [ ` put* ` opts] ( #put-options )
37
36
* [ ` rm.all ` ] ( #rm-all )
38
37
* [ ` rm.entry ` ] ( #rm-entry )
39
38
* [ ` rm.content ` ] ( #rm-content )
@@ -92,7 +91,7 @@ cacache.get.byDigest(cachePath, integrityHash).then(data => {
92
91
* Lockless, high-concurrency cache access
93
92
* Streaming support
94
93
* Promise support
95
- * Pretty darn fast -- sub-millisecond reads and writes including verification
94
+ * Fast -- sub-millisecond reads and writes including verification
96
95
* Arbitrary metadata storage
97
96
* Garbage collection and additional offline verification
98
97
* Thorough test coverage
@@ -201,6 +200,8 @@ A sub-function, `get.byDigest` may be used for identical behavior, except lookup
201
200
will happen by integrity hash, bypassing the index entirely. This version of the
202
201
function * only* returns ` data ` itself, without any wrapper.
203
202
203
+ See: [ options] ( #get-options )
204
+
204
205
##### Note
205
206
206
207
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,
242
243
except lookup will happen by integrity hash, bypassing the index entirely. This
243
244
version does not emit the ` metadata ` and ` integrity ` events at all.
244
245
246
+ See: [ options] ( #get-options )
247
+
245
248
##### Example
246
249
247
250
``` javascript
@@ -328,12 +331,33 @@ cacache.get.hasContent(cachePath, 'sha521-NOT+IN/CACHE==').then(console.log)
328
331
false
329
332
```
330
333
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
+
331
353
#### <a name =" put-data " ></a > ` > cacache.put(cache, key, data, [opts]) -> Promise `
332
354
333
355
Inserts data passed to it into the cache. The returned Promise resolves with a
334
356
digest (generated according to [ ` opts.algorithms ` ] ( #optsalgorithms ) ) after the
335
357
cache entry has been successfully written.
336
358
359
+ See: [ options] ( #put-options )
360
+
337
361
##### Example
338
362
339
363
``` javascript
@@ -353,6 +377,8 @@ Stream](https://nodejs.org/api/stream.html#stream_writable_streams) that inserts
353
377
data written to it into the cache. Emits an ` integrity ` event with the digest of
354
378
written contents when it succeeds.
355
379
380
+ See: [ options] ( #put-options )
381
+
356
382
##### Example
357
383
358
384
``` javascript
@@ -365,9 +391,7 @@ request.get(
365
391
)
366
392
```
367
393
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
371
395
372
396
##### ` opts.metadata `
373
397
@@ -382,7 +406,7 @@ with an `EBADSIZE` error.
382
406
##### ` opts.integrity `
383
407
384
408
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
386
410
with an ` EINTEGRITY ` error.
387
411
388
412
` algorithms ` has no effect if this option is present.
@@ -415,6 +439,11 @@ cache.
415
439
Reading from disk data can be forced by explicitly passing ` memoize: false ` to
416
440
the reader functions, but their default will be to read from memory.
417
441
442
+ ##### ` opts.tmpPrefix `
443
+ Default: null
444
+
445
+ Prefix to append on the temporary directory name inside the cache's tmp dir.
446
+
418
447
#### <a name =" rm-all " ></a > ` > cacache.rm.all(cache) -> Promise `
419
448
420
449
Clears the entire cache. Mainly by blowing away the cache directory itself.
@@ -478,6 +507,8 @@ permissions.
478
507
If you want automatic cleanup of this directory, use
479
508
[ ` tmp.withTmp() ` ] ( #with-tpm )
480
509
510
+ See: [ options] ( #tmp-options )
511
+
481
512
##### Example
482
513
483
514
``` javascript
@@ -517,6 +548,8 @@ promise completes.
517
548
The same caveats apply when it comes to managing permissions for the tmp dir's
518
549
contents.
519
550
551
+ See: [ options] ( #tmp-options )
552
+
520
553
##### Example
521
554
522
555
``` javascript
@@ -527,6 +560,13 @@ cacache.tmp.withTmp(cache, dir => {
527
560
})
528
561
```
529
562
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
+
530
570
#### <a name =" integrity " ></a > Subresource Integrity Digests
531
571
532
572
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
582
622
process, including amount of storage reclaimed, number of valid entries, number
583
623
of entries removed, etc.
584
624
585
- ##### Options
625
+ ##### <a name =" verify-options " ></a > Options
626
+
627
+ ##### ` opts.concurrency `
628
+
629
+ Default: 20
586
630
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
+ ```
589
643
590
644
##### Example
591
645
0 commit comments