Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
cache-point
Advanced tools
A memoisation solution intended to cache the output of expensive operations, speeding up future invocations with the same input.
Example
const Cache = require('cache-point')
const cache = new Cache({ dir: 'tmp/example' })
// The first invocation will take 3s, the rest instantaneous.
// outputs: 'result'
getData('some input')
.then(console.log)
// check the cache for output generated with this input.
// cache.read() will resolve on hit, reject on miss.
function getData (input) {
return cache
.read(input)
.catch(() => expensiveOperation(input))
}
// The expensive operation we're aiming to avoid,
// (3 second cost per invocation)
function expensiveOperation (input) {
return new Promise((resolve, reject) => {
setTimeout(() => {
const output = 'result'
cache.write(input, output)
resolve(output)
}, 3000)
})
}
string
Promise
string
Promise
string
Promise
Promise
Param | Type |
---|---|
[options] | object |
[options.dir] | string |
string
Current cache directory. Can be changed at any time.
Kind: instance property of Cache
Promise
A cache hit resolves with the stored value, a miss rejects.
Kind: instance method of Cache
Param | Type | Description |
---|---|---|
keys | * | One or more values to uniquely identify the data. Can be any value, or an array of values of any type. |
string
A cache hit returns the stored value, a miss returns null
.
Kind: instance method of Cache
Param | Type | Description |
---|---|---|
keys | * | One or more values to uniquely identify the data. Can be any value, or an array of values of any type. |
Promise
Write some data to the cache. Returns a promise which resolves when the write is complete.
Kind: instance method of Cache
Param | Type | Description |
---|---|---|
keys | * | One or more values to index the data, e.g. a request object or set of function args. |
content | * | the data to store |
Write some data to the cache with a key.
Kind: instance method of Cache
Param | Type | Description |
---|---|---|
keys | * | One or more values to index the data, e.g. a request object or set of function args. |
content | * | the data to store |
string
Used internally to convert a key value into a hex checksum. Override if for some reason you need a different hashing strategy.
Kind: instance method of Cache
Param | Type | Description |
---|---|---|
keys | * | One or more values to index the data, e.g. a request object or set of function args. |
Promise
Clears the cache. Returns a promise which resolves once the cache is clear.
Kind: instance method of Cache
Promise
Clears and removes the cache directory. Returns a promise which resolves once the remove is complete.
Kind: instance method of Cache
© 2016 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.
FAQs
Simple, filesystem-backed memoisation cache.
The npm package cache-point receives a total of 0 weekly downloads. As such, cache-point popularity was classified as not popular.
We found that cache-point demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.