@vltpkg/cache-unzip

0.0.0-13 • Public • Published

cache-unzip

@vltpkg/cache-unzip

This is a script that can be run as a detached background process to un-gzip any cached response bodies in the vlt cache.

Usage · Why Do This?

Usage

Whenever you get a cache entry with a gzipped body, tell this module about it.

import { register } from '@vltpkg/cache-unzip'
import { Cache } from '@vltpkg/cache'

const cache = new Cache({ path: cachePath })

// later...

const response = get_response_cache_entry_somehow()
cache.set(myKey, response.encode())

// unzip it after this process is done
if (response.isGzip) {
  register(cachePath, myKey)
}

On process exit, these registered keys will be passed as arguments to a detached deref'ed vlt-cache-unzip process. So, the main program exits normally, but the worker ignores the SIGHUP and keeps going until it's done. The next time that cache entry is read, it won't have to be unzipped.

Why Do This

Because it's faster to not have to decompress the same content more times than necessary.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.0-1369latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.0-1369
0.0.0-1210
0.0.0-112
0.0.0-102
0.0.0-91
0.0.0-80
0.0.0-71
0.0.0-60
0.0.0-50
0.0.0-40
0.0.0-31
0.0.0-20
0.0.0-0.17307243425810
0.0.0-0.17302392483250

Package Sidebar

Install

npm i @vltpkg/cache-unzip

Weekly Downloads

86

Version

0.0.0-13

License

BSD-2-Clause-Patent

Unpacked Size

30.3 kB

Total Files

12

Last publish

Collaborators

  • ruyadorno
  • darcyclarke
  • vltops
  • isaacs
  • lukekarrys