New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

got-cached

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got-cached

Got response cache for get requests

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

got-cached

Got cached is a provider of a cache wrapper around got (for http GET requests). Cache is expected to to have functions set(key, value) and get(key) (returning a Promise that resolves the value).

note: cache hits only include response.status (200) and response.body

import fs from 'fs'
import { createClient } from 'then-redis'
import gotCached from 'got-cached'

const expiry = 600
const redis = createClient()
const options = {
  cache: {
    get: (key) => redis.get(key),
    set: (key, value) => redis.send('set', [key, value, 'EX', expiry])
  }
}

const got = gotCached(options)

got('http://httpbin.org/get').then((response) => {
  console.log(response.body)
})

// Streams are not cached, but still play nicely
got.stream('todomvc.com').pipe(fs.createWriteStream('index.html'))

FAQs

Package last updated on 22 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc